From: Keith Busch Date: Mon, 19 Dec 2016 15:21:56 +0000 (-0500) Subject: Fix compiler warning, asprintf usage X-Git-Tag: v1.1~2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=1d6381c42dabc6c93fa3065b39f8f5e4e9ba812c;p=users%2Fsagi%2Fnvme-cli.git Fix compiler warning, asprintf usage Reported-by: Yachun Liu Signed-off-by: Keith Busch --- diff --git a/fabrics.c b/fabrics.c index a9898d15..362ca6f1 100644 --- 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)