Re: [PATCH] nfp: Fix memory leak in nfp_resource_acquire()

From: Keita Suzuki
Date: Thu Apr 09 2020 - 13:38:50 EST


Hi,

So sorry about this. It seems like I accidentally touched the patch
file after generating / testing the patch.
I will resend the new patch immediately.

I have tested the patch using kmemleak.

Thanks.

2020å4æ10æ(é) 2:18 David Miller <davem@xxxxxxxxxxxxx>:
>
> From: Keita Suzuki <keitasuzuki.park@xxxxxxxxxxxxxxxxxxxx>
> Date: Thu, 9 Apr 2020 15:02:07 +0000
>
> > This patch fixes a memory leak in nfp_resource_acquire(). res->mutex is
> > alllocated in nfp_resource_try_acquire(). However, when
> > msleep_interruptible() or time_is_before_eq_jiffies() fails, it falls
> > into err_fails path where res is freed, but res->mutex is not.
> >
> > Fix this by changing call to free to nfp_resource_release().
> >
> > Signed-off-by: Keita Suzuki <keitasuzuki.park@xxxxxxxxxxxxxxxxxxxx>
>
> Did you test compile this?
>
> drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c: In function ânfp_resource_acquireâ:
> drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c:203:2: error: implicit declaration of function ânfp_resource_relaseâ; did you mean ânfp_resource_releaseâ? [-Werror=implicit-function-declaration]
> nfp_resource_relase(res);
> ^~~~~~~~~~~~~~~~~~~
> nfp_resource_release
>
> And this makes me feel like the test was not runtime tested either.