ipv4: nexthop: Fix deadcode issue by performing a proper NULL check
authorPatrick Eigensatz <patrickeigensatz@gmail.com>
Mon, 1 Jun 2020 11:12:01 +0000 (13:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 1 Jun 2020 18:05:35 +0000 (11:05 -0700)
commitdafe2078a75af1abe4780313ef8dd8491ba8598f
treed59bf4e8f60ebc1603d125d25c9290672993275c
parent07f6ecec65547099d0e5ea1b1fba748c4b90eaf0
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 <scan-admin@coverity.com>
Signed-off-by: Patrick Eigensatz <patrickeigensatz@gmail.com>
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/nexthop.c