From ea5f4c4c578f93557e58c4df708b3c0e5256836d Mon Sep 17 00:00:00 2001 From: Mobashshera Rasool Date: Fri, 11 Mar 2022 09:57:10 -0800 Subject: [PATCH] pimd: Fix Null pointer dereferences 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 --- pimd/pim_cmd_common.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 442760fdfe..c5d89f8065 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -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