From 2faba14459636862be63a9d06d1f6ee2dd61f686 Mon Sep 17 00:00:00 2001 From: Jafar Al-Gharaibeh Date: Wed, 4 Dec 2024 14:57:13 -0600 Subject: [PATCH] pimd: Prevent crash of pim when auto-rp's socket is not initialized If the socket associated with the auto-rp fails to initialize then the memory for the auto-rp is just dropped on the floor. Additionally any type of attempt at using the feature will just cause pimd to crash, when the pointer is derefed. Since it is derefed all over the place without checking. Clearly if you cannot bind/use the socket let's allow continuation. Fixes: #17540 Signed-off-by: Donald Sharp --- pimd/pim_autorp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pimd/pim_autorp.c b/pimd/pim_autorp.c index df4f809b3da2..a07bd4ab3af7 100644 --- a/pimd/pim_autorp.c +++ b/pimd/pim_autorp.c @@ -1014,12 +1014,13 @@ void pim_autorp_init(struct pim_instance *pim) autorp->announce_interval = DEFAULT_ANNOUNCE_INTERVAL; autorp->announce_holdtime = DEFAULT_ANNOUNCE_HOLDTIME; + pim->autorp = autorp; + if (!pim_autorp_socket_enable(autorp)) { - zlog_err("%s: AutoRP failed to initialize", __func__); + zlog_err("%s: AutoRP failed to initialize, feature will not work correctly", __func__); return; } - pim->autorp = autorp; if (PIM_DEBUG_AUTORP) zlog_debug("%s: AutoRP Initialized", __func__);