aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Dreier <roland@purestorage.com>2018-01-11 16:38:00 -0500
committerChristoph Hellwig <hch@lst.de>2018-01-15 11:09:31 -0500
commitdf351ef73789345b4b6c00434c5fd1fca7175643 (patch)
treeb6564018f48115e5489dd9066f266cbd3b70444a
parent8adb8c147b2f6383a1676325c27e3dbc29d2fba7 (diff)
nvme-fabrics: fix memory leak when parsing host ID option
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@purestorage.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
-rw-r--r--drivers/nvme/host/fabrics.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 2f68befd31bf..eb46967bb0d5 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,
738 ret = -ENOMEM; 738 ret = -ENOMEM;
739 goto out; 739 goto out;
740 } 740 }
741 if (uuid_parse(p, &hostid)) { 741 ret = uuid_parse(p, &hostid);
742 kfree(p);
743 if (ret) {
742 pr_err("Invalid hostid %s\n", p); 744 pr_err("Invalid hostid %s\n", p);
743 ret = -EINVAL; 745 ret = -EINVAL;
744 goto out; 746 goto out;