mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 09:19:51 +00:00
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>
This commit is contained in:
parent
07f6ecec65
commit
dafe2078a7
1 changed files with 2 additions and 2 deletions
|
@ -1185,10 +1185,10 @@ static struct nexthop *nexthop_create_group(struct net *net,
|
||||||
|
|
||||||
/* spare group used for removals */
|
/* spare group used for removals */
|
||||||
nhg->spare = nexthop_grp_alloc(num_nh);
|
nhg->spare = nexthop_grp_alloc(num_nh);
|
||||||
if (!nhg) {
|
if (!nhg->spare) {
|
||||||
kfree(nhg);
|
kfree(nhg);
|
||||||
kfree(nh);
|
kfree(nh);
|
||||||
return NULL;
|
return ERR_PTR(-ENOMEM);
|
||||||
}
|
}
|
||||||
nhg->spare->spare = nhg;
|
nhg->spare->spare = nhg;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue