lkml.org 
[lkml]   [2020]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] ipv4: nexthop: Fix deadcode issue by performing a proper NULL check
From
Date
On 01/06/2020 14:12, patrickeigensatz@gmail.com wrote:
> From: Patrick Eigensatz <patrickeigensatz@gmail.com>
>
> 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>
> ---
> net/ipv4/nexthop.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
> index 563f71bcb2d7..cb9412cd5e4b 100644
> --- a/net/ipv4/nexthop.c
> +++ b/net/ipv4/nexthop.c
> @@ -1118,10 +1118,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;
>
>

As Colin's similar patch[1] was rejected recently, this one also fixes the issue.
This is targeted at -net.

Fixes: 90f33bffa382 ("nexthops: don't modify published nexthop groups")
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

Thanks!

[1] https://lkml.org/lkml/2020/5/28/909

\
 
 \ /
  Last update: 2020-06-01 13:19    [W:0.375 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site