Skip to content

Commit dafe207

Browse files
pentixdavem330
authored andcommitted
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 <[email protected]> Signed-off-by: Patrick Eigensatz <[email protected]> Acked-by: Nikolay Aleksandrov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 07f6ece commit dafe207

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/ipv4/nexthop.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,10 +1185,10 @@ static struct nexthop *nexthop_create_group(struct net *net,
11851185

11861186
/* spare group used for removals */
11871187
nhg->spare = nexthop_grp_alloc(num_nh);
1188-
if (!nhg) {
1188+
if (!nhg->spare) {
11891189
kfree(nhg);
11901190
kfree(nh);
1191-
return NULL;
1191+
return ERR_PTR(-ENOMEM);
11921192
}
11931193
nhg->spare->spare = nhg;
11941194

0 commit comments

Comments
 (0)