Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: roland@kernel.org (Roland Dreier)
Subject: [PATCH 1/2] nvme-fabrics: Fix memory leak when parsing host ID option
Date: Thu, 11 Jan 2018 13:38:00 -0800	[thread overview]
Message-ID: <20180111213800.1767-1-roland@kernel.org> (raw)

From: Roland Dreier <roland@purestorage.com>

We use match_strdup() to get a copy of the option string for host ID string, but
we just pass it to uuid_parse() and don't store the string pointer, so we need to
kfree() the string after parsing it.

Signed-off-by: Roland Dreier <roland at purestorage.com>
---
 drivers/nvme/host/fabrics.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 76b4fe6816a0..2ba52f9f8185 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -738,7 +738,9 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
 				ret = -ENOMEM;
 				goto out;
 			}
-			if (uuid_parse(p, &hostid)) {
+			ret = uuid_parse(p, &hostid);
+			kfree(p);
+			if (ret) {
 				pr_err("Invalid hostid %s\n", p);
 				ret = -EINVAL;
 				goto out;
-- 
2.14.1

             reply	other threads:[~2018-01-11 21:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11 21:38 Roland Dreier [this message]
2018-01-12 10:16 ` [PATCH 1/2] nvme-fabrics: Fix memory leak when parsing host ID option Johannes Thumshirn
2018-01-12 20:00   ` Roland Dreier
2018-01-14  9:27     ` Sagi Grimberg
2018-01-15  7:44     ` Johannes Thumshirn
2018-01-15 15:23 ` Christoph Hellwig

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=20180111213800.1767-1-roland@kernel.org \
    --to=roland@kernel.org \
    /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