net: route: Check that neighbor exists before deleting it

If the neighbour does not exists, then the route to it cannot
be deleted so we can return error to caller in that case.

Coverity-CID: 188173
Fixes #10090

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

View file

@ -531,6 +531,9 @@ int net_route_del_by_nexthop_data(struct net_if *iface,
NET_ASSERT(nexthop);
nbr_nexthop = net_ipv6_nbr_lookup(iface, nexthop);
if (!nbr_nexthop) {
return -EINVAL;
}
for (i = 0; i < CONFIG_NET_MAX_ROUTES; i++) {
struct net_nbr *nbr = get_nbr(i);