]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
Fix compiler warning, asprintf usage
authorKeith Busch <keith.busch@intel.com>
Mon, 19 Dec 2016 15:21:56 +0000 (10:21 -0500)
committerKeith Busch <keith.busch@intel.com>
Mon, 19 Dec 2016 15:23:09 +0000 (10:23 -0500)
Reported-by: Yachun Liu <D201577676@hust.edu.cn>
Signed-off-by: Keith Busch <keith.busch@intel.com>
fabrics.c

index a9898d15a71280f25c0532874273c236da758cf3..362ca6f12001d371a138491a8026241f4bb26a5c 100644 (file)
--- a/fabrics.c
+++ b/fabrics.c
@@ -813,12 +813,14 @@ static int scan_sys_nvme_filter(const struct dirent *d)
  */
 static int disconnect_subsys(char *nqn, char *ctrl)
 {
-       char *sysfs_nqn_path, *sysfs_del_path;;
+       char *sysfs_nqn_path = NULL, *sysfs_del_path = NULL;
        char subsysnqn[NVMF_NQN_SIZE] = {};
        int fd, ret = 0;
 
-       asprintf(&sysfs_nqn_path, "%s/%s/subsysnqn", SYS_NVME, ctrl);
-       asprintf(&sysfs_del_path, "%s/%s/delete_controller", SYS_NVME, ctrl);
+       if (asprintf(&sysfs_nqn_path, "%s/%s/subsysnqn", SYS_NVME, ctrl) < 0)
+               goto free;
+       if (asprintf(&sysfs_del_path, "%s/%s/delete_controller", SYS_NVME, ctrl) < 0)
+               goto free;
 
        fd = open(sysfs_nqn_path, O_RDONLY);
        if (fd < 0)