linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] nfp: Fix memory leak in nfp_resource_acquire()
@ 2020-04-09 15:02 Keita Suzuki
  2020-04-09 17:18 ` David Miller
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Keita Suzuki @ 2020-04-09 15:02 UTC (permalink / raw)
  Cc: keitasuzuki.park, takafumi.kubota1012, Jakub Kicinski,
	David S. Miller, open list:NETRONOME ETHERNET DRIVERS,
	open list:NETWORKING DRIVERS, open list

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(-)

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);
 }
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-04-20  7:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-09 15:02 [PATCH] nfp: Fix memory leak in nfp_resource_acquire() Keita Suzuki
2020-04-09 17:18 ` David Miller
2020-04-09 17:38   ` Keita Suzuki
2020-04-09 17:41 ` Keita Suzuki
2020-04-09 19:32   ` Jakub Kicinski
2020-04-10  5:21     ` Keita Suzuki
2020-04-20  7:49 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).