From 9de5b3bf58988b4ec5d663aaebda8906126ad29f Mon Sep 17 00:00:00 2001 From: Carmine Scarpitta Date: Fri, 15 Sep 2023 12:30:39 +0200 Subject: isisd: Fix CID 1568133 (Null pointer dereference) Null checking the `sra` pointer after dereferencing it causes a coverity issue. Let's perform the null check before dereferencing the pointer. Fixes this coverity issue: *** CID 1568133: Null pointer dereferences (REVERSE_INULL) /isisd/isis_zebra.c: 1077 in isis_zebra_srv6_adj_sid_uninstall() 1071 enum seg6local_action_t action = ZEBRA_SEG6_LOCAL_ACTION_UNSPEC; 1072 struct interface *ifp; 1073 uint16_t prefixlen = IPV6_MAX_BITLEN; 1074 struct isis_circuit *circuit = sra->adj->circuit; 1075 struct isis_area *area = circuit->area; 1076 >>> CID 1568133: Null pointer dereferences (REVERSE_INULL) >>> Null-checking "sra" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. 1077 if (!sra) 1078 return; 1079 1080 switch (sra->behavior) { 1081 case SRV6_ENDPOINT_BEHAVIOR_END_X: 1082 prefixlen = IPV6_MAX_BITLEN; Signed-off-by: Carmine Scarpitta --- isisd/isis_zebra.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index 6b9507136..378d78efe 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -1074,12 +1074,15 @@ void isis_zebra_srv6_adj_sid_uninstall(struct srv6_adjacency *sra) enum seg6local_action_t action = ZEBRA_SEG6_LOCAL_ACTION_UNSPEC; struct interface *ifp; uint16_t prefixlen = IPV6_MAX_BITLEN; - struct isis_circuit *circuit = sra->adj->circuit; - struct isis_area *area = circuit->area; + struct isis_circuit *circuit; + struct isis_area *area; if (!sra) return; + circuit = sra->adj->circuit; + area = circuit->area; + switch (sra->behavior) { case SRV6_ENDPOINT_BEHAVIOR_END_X: prefixlen = IPV6_MAX_BITLEN; -- cgit v1.2.3