nvme-fabrics: Fix memory leak when parsing host ID option
PATCH 1/2 nvme-fabrics: Fix memory leak when parsing host ID option
From: Roland Dreier <[email protected]>
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.
--- drivers/nvme/host/fabrics.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/nvme/host/fabrics.c +3 -1
@@ -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;
Signature · 1 line
2.14.1
PATCH 1/2 nvme-fabrics: Fix memory leak when parsing host ID option
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>
Do you mind fixing the same pattern on:
- NVMF_OPT_TRANSPORT
- NVMF_OPT_NQN
- NVMF_OPT_TRADDR
- NVMF_OPT_TRSVCID
- NVMF_OPT_HOST_TRADDR
as well?
Thanks,
Johannes
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 1/2 nvme-fabrics: Fix memory leak when parsing host ID option
Quoted 10 lines · Johannes Thumshirn
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>Do you mind fixing the same pattern on:
-NVMF_OPT_TRANSPORT
-NVMF_OPT_NQN
-NVMF_OPT_TRADDR
-NVMF_OPT_TRSVCID
-NVMF_OPT_HOST_TRADDR
as well?
Thanks for the review. I don't think the same pattern is there for the other options - a pointer to the string is
stored in opts and freed in nvmf_free_options(). NVMF_OPT_HOST_ID is unique in that we don't stash the
strdup'ed pointer anywhere.
- R.
Sagi Grimberg
maintainerPATCH 1/2 nvme-fabrics: Fix memory leak when parsing host ID option
Quoted 6 lines
Thanks for the review. I don't think the same pattern is there for the other options - a pointer to the string is
stored in opts and freed innvmf_free_options().NVMF_OPT_HOST_IDis unique in that we don't stash the
strdup'ed pointer anywhere.
Agreed, thanks Roland,
PATCH 1/2 nvme-fabrics: Fix memory leak when parsing host ID option
In reply to Roland DreierQuoted 12 lines · Roland Dreier
Quoted 10 lines · Johannes Thumshirn
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn at suse.de>Do you mind fixing the same pattern on:
-NVMF_OPT_TRANSPORT
-NVMF_OPT_NQN
-NVMF_OPT_TRADDR
-NVMF_OPT_TRSVCID
-NVMF_OPT_HOST_TRADDR
as well?
Quoted 5 lines
Thanks for the review. I don't think the same pattern is there for the other options - a pointer to the string is
stored in opts and freed innvmf_free_options().NVMF_OPT_HOST_IDis unique in that we don't stash the
strdup'ed pointer anywhere.
Correct. I'm sorry for the false alarm.
Signature · 6 lines
Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
PATCH 1/2 nvme-fabrics: Fix memory leak when parsing host ID option
In reply to Roland DreierThanks,
applied to nvme-4.16.