]> git.puffer.fish Git - matthieu/frr.git/commitdiff
pimd: Fix Null pointer dereferences
authorMobashshera Rasool <mrasool@vmware.com>
Fri, 11 Mar 2022 17:57:10 +0000 (09:57 -0800)
committerMobashshera Rasool <mrasool@vmware.com>
Fri, 11 Mar 2022 18:07:01 +0000 (10:07 -0800)
Fixing the below problem:
Dereferencing a pointer that might be "NULL" "group_dnode"
when calling "yang_is_last_list_dnode" in api pim_process_no_rp_cmd

Although there is no NULL pointer dereference since
yang_dnode_exists is called before using the dnode.
So removing the unnecessary yang_dnode_exists api call
and directly get the node and if node does not exists,
return.

Signed-off-by: Mobashshera Rasool <mrasool@vmware.com>
pimd/pim_cmd_common.c

index 442760fdfe22e6d20140b4d0ae62f15660415a89..c5d89f80650e691d419a233eecf8be278b61806a 100644 (file)
@@ -582,13 +582,12 @@ int pim_process_no_rp_cmd(struct vty *vty, const char *rp_str,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       if (!yang_dnode_exists(vty->candidate_config->dnode, group_xpath)) {
+       group_dnode = yang_dnode_get(vty->candidate_config->dnode, group_xpath);
+       if (!group_dnode) {
                vty_out(vty, "%% Unable to find specified RP\n");
                return NB_OK;
        }
 
-       group_dnode = yang_dnode_get(vty->candidate_config->dnode, group_xpath);
-
        if (yang_is_last_list_dnode(group_dnode))
                nb_cli_enqueue_change(vty, rp_xpath, NB_OP_DESTROY, NULL);
        else