From: Keita Suzuki <keitasuzuki.park@sslab.ics.keio.ac.jp>
To: unlisted-recipients:; (no To-header on input)
Cc: keitasuzuki.park@sslab.ics.keio.ac.jp,
takafumi.kubota1012@sslab.ics.keio.ac.jp,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
oss-drivers@netronome.com (open list:NETRONOME ETHERNET DRIVERS),
netdev@vger.kernel.org (open list:NETWORKING DRIVERS),
linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] nfp: Fix memory leak in nfp_resource_acquire()
Date: Thu, 9 Apr 2020 15:02:07 +0000 [thread overview]
Message-ID: <20200409150210.15488-1-keitasuzuki.park@sslab.ics.keio.ac.jp> (raw)
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
next reply other threads:[~2020-04-09 15:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-09 15:02 Keita Suzuki [this message]
2020-04-09 17:18 ` [PATCH] nfp: Fix memory leak in nfp_resource_acquire() 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200409150210.15488-1-keitasuzuki.park@sslab.ics.keio.ac.jp \
--to=keitasuzuki.park@sslab.ics.keio.ac.jp \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
--cc=takafumi.kubota1012@sslab.ics.keio.ac.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).