From 1d6381c42dabc6c93fa3065b39f8f5e4e9ba812c Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Mon, 19 Dec 2016 10:21:56 -0500 Subject: [PATCH] Fix compiler warning, asprintf usage Reported-by: Yachun Liu Signed-off-by: Keith Busch --- fabrics.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) -- 2.51.0