From e2116917e579d52a27e64953161c24f0e5e4d551 Mon Sep 17 00:00:00 2001 From: sarita patra Date: Mon, 4 Apr 2022 03:53:36 -0700 Subject: [PATCH 1/3] pimd: fix pim_instance NULL deference in pim_vxlan_mlag_update Fixing the below coverity issue. >>> CID 1515545: (NULL_RETURNS) >>> Dereferencing a pointer that might be "NULL" "pim" when calling "pim_vxlan_set_peerlink_rif". 902 pim_vxlan_set_peerlink_rif(pim, NULL); Signed-off-by: sarita patra --- pimd/pim_vxlan.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pimd/pim_vxlan.c b/pimd/pim_vxlan.c index 5e55b9f9c8..e4d969daee 100644 --- a/pimd/pim_vxlan.c +++ b/pimd/pim_vxlan.c @@ -880,6 +880,12 @@ void pim_vxlan_mlag_update(bool enable, bool peer_state, uint32_t role, */ pim = pim_get_pim_instance(VRF_DEFAULT); + if (!pim) { + if (PIM_DEBUG_VXLAN) + zlog_debug("%s: Unable to find pim instance", __func__); + return; + } + if (enable) vxlan_mlag.flags |= PIM_VXLAN_MLAGF_ENABLED; else From e2067d591bb981225eaceb5ba7bf8d679e242689 Mon Sep 17 00:00:00 2001 From: sarita patra Date: Mon, 4 Apr 2022 03:54:42 -0700 Subject: [PATCH 2/3] pimd: fix pim_instance NULL deference in pim_zebra_if_address_add Signed-off-by: sarita patra --- pimd/pim_zebra.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 7f463715a5..4bed8d5b73 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -166,6 +166,13 @@ static int pim_zebra_if_address_add(ZAPI_CALLBACK_ARGS) struct pim_instance *pim; pim = pim_get_pim_instance(vrf_id); + if (!pim) { + if (PIM_DEBUG_ZEBRA) + zlog_debug("%s: Unable to find pim instance", + __func__); + return 0; + } + pim_ifp->pim = pim; pim_rp_check_on_if_add(pim_ifp); From 75a5ac751a9528682c5fe8518e0924b5d5f01424 Mon Sep 17 00:00:00 2001 From: sarita patra Date: Mon, 4 Apr 2022 03:55:23 -0700 Subject: [PATCH 3/3] pimd: fix pim_instance NULL deference in zclient_lookup_read_pipe Fixing the below coverity issue. >>> CID 1515546: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing a pointer that might be "NULL" "pim" when calling "zclient_lookup_nexthop_once". 391 zclient_lookup_nexthop_once(pim, nexthop_tab, 10, l); Signed-off-by: sarita patra --- pimd/pim_zlookup.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index c487f995e7..5d99f131a8 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -388,6 +388,12 @@ void zclient_lookup_read_pipe(struct thread *thread) struct pim_zlookup_nexthop nexthop_tab[10]; struct in_addr l = {.s_addr = INADDR_ANY}; + if (!pim) { + if (PIM_DEBUG_PIM_NHT_DETAIL) + zlog_debug("%s: Unable to find pim instance", __func__); + return; + } + zclient_lookup_nexthop_once(pim, nexthop_tab, 10, l); thread_add_timer(router->master, zclient_lookup_read_pipe, zlookup, 60, &zlookup_read);