]> granicus.if.org Git - zfs/commitdiff
Fix coverity defects: CID 147606, 147609
authorcao <cao.xuewen@zte.com.cn>
Wed, 12 Oct 2016 18:16:47 +0000 (02:16 +0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 12 Oct 2016 18:16:47 +0000 (11:16 -0700)
coverity scan CID:147606, Type:resource leak
coverity scan CID:147609, Type:resource leak

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5245

cmd/ztest/ztest.c
lib/libzfs/libzfs_pool.c
tests/zfs-tests/cmd/dir_rd_update/dir_rd_update.c

index 1491e87344aea2c849f53e0da79c45f87c70112f..2e4dae3a95cb024295c56d32619f473478f08d5f 100644 (file)
@@ -6281,8 +6281,11 @@ ztest_run(ztest_shared_t *zs)
                kthread_t *thread;
 
                if (t < ztest_opts.zo_datasets &&
-                   ztest_dataset_open(t) != 0)
+                   ztest_dataset_open(t) != 0) {
+                       umem_free(tid,
+                           ztest_opts.zo_threads * sizeof (kt_did_t));
                        return;
+               }
 
                VERIFY3P(thread = zk_thread_create(NULL, 0,
                    (thread_func_t)ztest_thread,
index 1122216747a9cdd7b87c7104d22640badfbf25b2..68cc5f3ee0023ac422543f2b4d2710eacad1596d 100644 (file)
@@ -4159,7 +4159,7 @@ zpool_label_name(char *label_name, int label_size)
        int fd;
 
        fd = open("/dev/urandom", O_RDONLY);
-       if (fd > 0) {
+       if (fd >= 0) {
                if (read(fd, &id, sizeof (id)) != sizeof (id))
                        id = 0;
 
index 3e075e3d708f0c7da79cb76d7cb3c3bd1500006e..64348549d96696804c5fad7cf74647d2fefc84be 100644 (file)
@@ -108,6 +108,7 @@ main(int argc, char **argv)
                        }
                        j++;
                }
+               (void) close(fd);
        } else if (pid == 0) {
                int fd = open(dirpath, O_RDONLY);
                int chownret;
@@ -128,6 +129,7 @@ main(int argc, char **argv)
 
                        k++;
                }
+               (void) close(fd);
        }
 
        return (0);