diff options
author | cao <[email protected]> | 2016-10-08 04:19:43 +0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-10-07 13:19:43 -0700 |
commit | ccc92611b1bd0a78a72f553472a91ef1e83b06c5 (patch) | |
tree | 119b75f97b2afab3eeafcbd1fdc81322c0512549 /lib | |
parent | 482cd9ee69e88710e9241fac220501ea4e101d19 (diff) |
Fix coverity defects: CID 147565-147567
coverity scan CID:147567, Type:dereference null return value
coverity scan CID:147566, Type:dereference null return value
coverity scan CID:147565, Type:dereference null return value
Reviewed by: Richard Laager <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: cao.xuewen <[email protected]>
Closes #5166
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libzpool/util.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/libzpool/util.c b/lib/libzpool/util.c index 7a0748c03..bc3bcbe78 100644 --- a/lib/libzpool/util.c +++ b/lib/libzpool/util.c @@ -123,13 +123,15 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent) for (c = 0; c < children; c++) { nvlist_t *cnv = child[c]; - char *cname, *tname; + char *cname = NULL, *tname; uint64_t np; + int len; if (nvlist_lookup_string(cnv, ZPOOL_CONFIG_PATH, &cname) && nvlist_lookup_string(cnv, ZPOOL_CONFIG_TYPE, &cname)) cname = "<unknown>"; - tname = calloc(1, strlen(cname) + 2); - (void) strcpy(tname, cname); + len = strlen(cname) + 2; + tname = umem_zalloc(len, UMEM_NOFAIL); + (void) strlcpy(tname, cname, len); if (nvlist_lookup_uint64(cnv, ZPOOL_CONFIG_NPARITY, &np) == 0) tname[strlen(tname)] = '0' + np; show_vdev_stats(tname, ctype, cnv, indent + 2); |