提交 dafe2078 编写于 作者: P Patrick Eigensatz 提交者: David S. Miller

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: NCoverity <scan-admin@coverity.com>
Signed-off-by: NPatrick Eigensatz <patrickeigensatz@gmail.com>
Acked-by: NNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 07f6ecec
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册