]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
ioctl: Free memory if get_property for fabrics failed
authorMinwoo Im <minwoo.im.dev@gmail.com>
Sat, 6 Apr 2019 21:45:16 +0000 (06:45 +0900)
committerMinwoo Im <minwoo.im.dev@gmail.com>
Sat, 6 Apr 2019 21:45:16 +0000 (06:45 +0900)
The given *pbar is allocated inside this function without freeing it
will be freed from the caller in case of show-regs subcommand for NVMe-oF
controller.

If Get Property is failed because it has PCIe transport, then it needs
to be freed here instead of caller.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
nvme-ioctl.c

index dbd8843b1982765007af0dce436a870c185fb9c2..e1f010d0881c5549edc7a68434b2a491eb7e30f0 100644 (file)
@@ -626,6 +626,8 @@ int nvme_get_properties(int fd, void **pbar)
                err = get_property_helper(fd, offset, *pbar + offset, &advance);
                if (!err)
                        ret = 0;
+               else
+                       free(*pbar);
        }
 
        return ret;