* [PATCH] nvme: don't free uuid pointer before printing it
@ 2018-01-25 8:09 Johannes Thumshirn
2018-01-25 9:37 ` Max Gurtovoy
2018-01-25 15:20 ` Christoph Hellwig
0 siblings, 2 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2018-01-25 8:09 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Sagi Grimberg, Keith Busch, Linux Kernel Mailinglist,
Linux NVMe Mailinglist, Dan Carpenter, Johannes Thumshirn,
Roland Dreier
Commit df351ef73789 ("nvme-fabrics: fix memory leak when parsing host ID
option") fixed the leak of 'p' but in case uuid_parse() fails the memory
is freed before the error print that is using it.
Free it after printing eventual errors.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Fixes: df351ef73789 ("nvme-fabrics: fix memory leak when parsing host ID option")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Roland Dreier <roland@purestorage.com>
---
drivers/nvme/host/fabrics.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index eb46967bb0d5..9cee72a80472 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -739,12 +739,13 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
goto out;
}
ret = uuid_parse(p, &hostid);
- kfree(p);
if (ret) {
pr_err("Invalid hostid %s\n", p);
ret = -EINVAL;
+ kfree(p);
goto out;
}
+ kfree(p);
break;
case NVMF_OPT_DUP_CONNECT:
opts->duplicate_connect = true;
--
2.13.6
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: don't free uuid pointer before printing it
2018-01-25 8:09 [PATCH] nvme: don't free uuid pointer before printing it Johannes Thumshirn
@ 2018-01-25 9:37 ` Max Gurtovoy
2018-01-25 15:20 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Max Gurtovoy @ 2018-01-25 9:37 UTC (permalink / raw)
To: Johannes Thumshirn, Christoph Hellwig
Cc: Roland Dreier, Sagi Grimberg, Linux Kernel Mailinglist,
Linux NVMe Mailinglist, Keith Busch, Dan Carpenter
On 1/25/2018 10:09 AM, Johannes Thumshirn wrote:
> Commit df351ef73789 ("nvme-fabrics: fix memory leak when parsing host ID
> option") fixed the leak of 'p' but in case uuid_parse() fails the memory
> is freed before the error print that is using it.
>
> Free it after printing eventual errors.
>
> Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
> Fixes: df351ef73789 ("nvme-fabrics: fix memory leak when parsing host ID option")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Cc: Roland Dreier <roland@purestorage.com>
> ---
> drivers/nvme/host/fabrics.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
> index eb46967bb0d5..9cee72a80472 100644
> --- a/drivers/nvme/host/fabrics.c
> +++ b/drivers/nvme/host/fabrics.c
> @@ -739,12 +739,13 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
> goto out;
> }
> ret = uuid_parse(p, &hostid);
> - kfree(p);
> if (ret) {
> pr_err("Invalid hostid %s\n", p);
> ret = -EINVAL;
> + kfree(p);
> goto out;
> }
> + kfree(p);
> break;
> case NVMF_OPT_DUP_CONNECT:
> opts->duplicate_connect = true;
>
Looks good,
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] nvme: don't free uuid pointer before printing it
2018-01-25 8:09 [PATCH] nvme: don't free uuid pointer before printing it Johannes Thumshirn
2018-01-25 9:37 ` Max Gurtovoy
@ 2018-01-25 15:20 ` Christoph Hellwig
1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2018-01-25 15:20 UTC (permalink / raw)
To: Johannes Thumshirn
Cc: Christoph Hellwig, Sagi Grimberg, Keith Busch,
Linux Kernel Mailinglist, Linux NVMe Mailinglist, Dan Carpenter,
Roland Dreier
On Thu, Jan 25, 2018 at 09:09:25AM +0100, Johannes Thumshirn wrote:
> Commit df351ef73789 ("nvme-fabrics: fix memory leak when parsing host ID
> option") fixed the leak of 'p' but in case uuid_parse() fails the memory
> is freed before the error print that is using it.
>
> Free it after printing eventual errors.
Thanks,
applied to nvme-4.16.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-25 15:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-25 8:09 [PATCH] nvme: don't free uuid pointer before printing it Johannes Thumshirn
2018-01-25 9:37 ` Max Gurtovoy
2018-01-25 15:20 ` Christoph Hellwig
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).