From: Patrick Eigensatz Date: Mon, 1 Jun 2020 11:12:01 +0000 (+0200) Subject: ipv4: nexthop: Fix deadcode issue by performing a proper NULL check X-Git-Tag: v5.10.7~2469^2~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dafe2078a75af1abe4780313ef8dd8491ba8598f;p=platform%2Fkernel%2Flinux-rpi.git ipv4: nexthop: Fix deadcode issue by performing a proper NULL check After allocating the spare nexthop group it should be tested for kzalloc() returning NULL, instead the already used nexthop group (which cannot be NULL at this point) had been tested so far. Additionally, if kzalloc() fails, return ERR_PTR(-ENOMEM) instead of NULL. Coverity-id: 1463885 Reported-by: Coverity Signed-off-by: Patrick Eigensatz Acked-by: Nikolay Aleksandrov Signed-off-by: David S. Miller --- diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index ebafa5e..400a9f8 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -1185,10 +1185,10 @@ static struct nexthop *nexthop_create_group(struct net *net, /* spare group used for removals */ nhg->spare = nexthop_grp_alloc(num_nh); - if (!nhg) { + if (!nhg->spare) { kfree(nhg); kfree(nh); - return NULL; + return ERR_PTR(-ENOMEM); } nhg->spare->spare = nhg;