net: route: Check NULL value in debug print

In net_route_add(), do not try to print route information if
route to neighbor is not found.

Coverity-CID: 188172
Fixes #10091

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2018-09-21 12:55:36 +03:00
parent c57f3a09bc
commit 3b8c37de45

View file

@ -366,13 +366,16 @@ struct net_route_entry *net_route_add(struct net_if *iface,
tmp = net_route_get_nexthop(route);
nbr = net_ipv6_nbr_lookup(iface, tmp);
llstorage = net_nbr_get_lladdr(nbr->idx);
if (nbr) {
llstorage = net_nbr_get_lladdr(nbr->idx);
NET_DBG("Removing the oldest route %s via %s [%s]",
net_sprint_ipv6_addr(&route->addr),
net_sprint_ipv6_addr(tmp),
net_sprint_ll_addr(llstorage->addr,
llstorage->len));
NET_DBG("Removing the oldest route %s "
"via %s [%s]",
net_sprint_ipv6_addr(&route->addr),
net_sprint_ipv6_addr(tmp),
net_sprint_ll_addr(llstorage->addr,
llstorage->len));
}
} while (0);
#endif /* CONFIG_NET_DEBUG_ROUTE */