Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] nvme-fabrics: Fix memory leak when parsing host ID option
@ 2018-01-11 21:38 Roland Dreier
  2018-01-12 10:16 ` Johannes Thumshirn
  2018-01-15 15:23 ` Christoph Hellwig
  0 siblings, 2 replies; 6+ messages in thread
From: Roland Dreier @ 2018-01-11 21:38 UTC (permalink / 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

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

end of thread, other threads:[~2018-01-15 15:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-11 21:38 [PATCH 1/2] nvme-fabrics: Fix memory leak when parsing host ID option Roland Dreier
2018-01-12 10:16 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox