]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
nvme: don't free uuid pointer before printing it
authorJohannes Thumshirn <jthumshirn@suse.de>
Thu, 25 Jan 2018 08:09:25 +0000 (09:09 +0100)
committerChristoph Hellwig <hch@lst.de>
Thu, 25 Jan 2018 17:41:39 +0000 (18:41 +0100)
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>
Reviewed-by: Max Gurtovoy <maxg@mellanox.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/host/fabrics.c

index eb46967bb0d5e04f6a92747e5d4575279c19a7e7..9cee72a80472946d02899d92db08d51d021ef57a 100644 (file)
@@ -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;