zebra: Remove possible NULL dereference in if_delete_connected

It is technically possible to attempt to use a NULL pointer.
Remove this from happening.

Additionally cleanup code indentation a small bit.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2017-12-13 10:32:54 -05:00
parent 9b7e34ec42
commit 070b4959fa

View File

@ -561,12 +561,13 @@ static void if_delete_connected(struct interface *ifp)
struct prefix cp; struct prefix cp;
struct route_node *rn; struct route_node *rn;
struct zebra_if *zebra_if; struct zebra_if *zebra_if;
struct listnode *node;
struct listnode *last = NULL;
zebra_if = ifp->info; zebra_if = ifp->info;
if (ifp->connected) { if (!ifp->connected)
struct listnode *node; return;
struct listnode *last = NULL;
while ((node = (last ? last->next while ((node = (last ? last->next
: listhead(ifp->connected)))) { : listhead(ifp->connected)))) {
@ -588,6 +589,7 @@ static void if_delete_connected(struct interface *ifp)
/* Remove addresses, secondaries first. */ /* Remove addresses, secondaries first. */
first = listhead(addr_list); first = listhead(addr_list);
if (first)
for (anode = first->next; anode || first; for (anode = first->next; anode || first;
anode = next) { anode = next) {
if (!anode) { if (!anode) {
@ -649,7 +651,6 @@ static void if_delete_connected(struct interface *ifp)
} }
} }
} }
}
/* Handle an interface delete event */ /* Handle an interface delete event */
void if_delete_update(struct interface *ifp) void if_delete_update(struct interface *ifp)