]> granicus.if.org Git - zfs/commitdiff
Fix coverity defects: CID 147565-147567
authorcao <cao.xuewen@zte.com.cn>
Fri, 7 Oct 2016 20:19:43 +0000 (04:19 +0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 7 Oct 2016 20:19:43 +0000 (13:19 -0700)
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 <rlaager@wiktel.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5166

lib/libzpool/util.c
module/zfs/bqueue.c
module/zfs/spa_config.c

index 7a0748c0322685835dd7a18770f1aac0cd9d58cc..bc3bcbe78e510fad07a0db8d6b7a302b59c5bbaf 100644 (file)
@@ -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);
index 89655cf538b48f6da730382013b1bb4414725526..0e490805c3ef964a03b39c992e6ac59857b34d18 100644 (file)
@@ -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);
index f31daf9eddf2d1c64e9f774db607b48d111af068..a3ff24bd5fdcafc4221c84e28bc9f852f334ec5b 100644 (file)
@@ -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);