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 | |
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
-rw-r--r-- | lib/libzpool/util.c | 8 | ||||
-rw-r--r-- | module/zfs/bqueue.c | 3 | ||||
-rw-r--r-- | module/zfs/spa_config.c | 1 |
3 files changed, 8 insertions, 4 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); diff --git a/module/zfs/bqueue.c b/module/zfs/bqueue.c index 89655cf53..0e490805c 100644 --- a/module/zfs/bqueue.c +++ b/module/zfs/bqueue.c @@ -87,13 +87,14 @@ bqueue_enqueue(bqueue_t *q, void *data, uint64_t item_size) void * bqueue_dequeue(bqueue_t *q) { - void *ret; + void *ret = NULL; uint64_t item_size; mutex_enter(&q->bq_lock); while (q->bq_size == 0) { cv_wait(&q->bq_pop_cv, &q->bq_lock); } ret = list_remove_head(&q->bq_list); + ASSERT3P(ret, !=, NULL); item_size = obj2node(q, ret)->bqn_size; q->bq_size -= item_size; mutex_exit(&q->bq_lock); diff --git a/module/zfs/spa_config.c b/module/zfs/spa_config.c index f31daf9ed..a3ff24bd5 100644 --- a/module/zfs/spa_config.c +++ b/module/zfs/spa_config.c @@ -270,6 +270,7 @@ spa_config_sync(spa_t *target, boolean_t removing, boolean_t postsysevent) mutex_enter(&spa->spa_props_lock); tdp = list_head(&spa->spa_config_list); if (spa->spa_config == NULL || + tdp == NULL || tdp->scd_path == NULL || strcmp(tdp->scd_path, dp->scd_path) != 0) { mutex_exit(&spa->spa_props_lock); |