summaryrefslogtreecommitdiff
path: root/usr
diff options
context:
space:
mode:
authorManjith Gambhir <manjith.gambhir@tegile.com>2018-05-22 12:07:25 +0000
committerHans Rosenfeld <rosenfeld@grumpf.hope-2000.org>2022-05-18 17:20:04 +0200
commitb602cbcd64fbbebf696bd7c8e03367bdfa19805d (patch)
tree9102536f656d597eed9e925e264b82e3c403995e /usr
parent9f7719e79a5c2ccdc9ee6a14147ba723fb8c0e36 (diff)
downloadillumos-joyent-b602cbcd64fbbebf696bd7c8e03367bdfa19805d.tar.gz
14696 nvmeadm command dumps core when libumem.so is used
Reviewed by: Andy Giles <agiles@tintri.com> Reviewed by: Ben Jameson <bjameson@tintri.com> Reviewed by: Pete Shephard <pete.shephard@tegile.com> Reviewed by: Robert Mustacchi <rm+illumos@fingolfin.org> Reviewed by: Jason King <jason.brian.king+illumos@gmail.com> Approved by: Dan McDonald <danmcd@mnx.io>
Diffstat (limited to 'usr')
-rw-r--r--usr/src/cmd/nvmeadm/nvmeadm.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/usr/src/cmd/nvmeadm/nvmeadm.c b/usr/src/cmd/nvmeadm/nvmeadm.c
index 3de4fa0b00..d78c7fe9ee 100644
--- a/usr/src/cmd/nvmeadm/nvmeadm.c
+++ b/usr/src/cmd/nvmeadm/nvmeadm.c
@@ -472,6 +472,8 @@ nvme_dskname(const nvme_process_arg_t *npa)
di_node_t child;
di_dim_t dim;
char *addr;
+ char *disk_ctd;
+ char *diskname = NULL;
dim = di_dim_init();
@@ -501,19 +503,23 @@ nvme_dskname(const nvme_process_arg_t *npa)
/* Chop off 's0' and get everything past the last '/' */
path[strlen(path) - 2] = '\0';
- path = strrchr(path, '/');
- if (path == NULL)
+ disk_ctd = strrchr(path, '/');
+ if (disk_ctd == NULL)
+ goto fail;
+ diskname = strdup(++disk_ctd);
+ if (diskname == NULL)
goto fail;
- path++;
+ free(path);
break;
}
di_dim_fini(dim);
- return (path);
+ return (diskname);
fail:
+ free(path);
err(-1, "nvme_dskname");
}
@@ -561,14 +567,15 @@ nvme_process(di_node_t node, di_minor_t minor, void *arg)
out:
di_devfs_path_free(npa->npa_path);
- free(npa->npa_dsk);
free(npa->npa_version);
free(npa->npa_idctl);
free(npa->npa_idns);
+ free(npa->npa_dsk);
npa->npa_version = NULL;
npa->npa_idctl = NULL;
npa->npa_idns = NULL;
+ npa->npa_dsk = NULL;
nvme_close(fd);