Message ID | 20200409150210.15488-1-keitasuzuki.park@sslab.ics.keio.ac.jp |
---|---|
State | New |
Headers | show |
Series | nfp: Fix memory leak in nfp_resource_acquire() | expand |
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c index ce7492a6a98f..95e7bdc95652 100644 --- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c +++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c @@ -200,7 +200,7 @@ nfp_resource_acquire(struct nfp_cpp *cpp, const char *name) err_free: nfp_cpp_mutex_free(dev_mutex); - kfree(res); + nfp_resource_relase(res); return ERR_PTR(err); }
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@sslab.ics.keio.ac.jp> --- drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)