Fix coverity defects: CID 147606, 147609

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
This commit is contained in:
cao 2016-10-13 02:16:47 +08:00 committed by Brian Behlendorf
parent af4db70f36
commit 06cf4d9890
3 changed files with 7 additions and 2 deletions

View File

@ -6281,8 +6281,11 @@ ztest_run(ztest_shared_t *zs)
kthread_t *thread; kthread_t *thread;
if (t < ztest_opts.zo_datasets && 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; return;
}
VERIFY3P(thread = zk_thread_create(NULL, 0, VERIFY3P(thread = zk_thread_create(NULL, 0,
(thread_func_t)ztest_thread, (thread_func_t)ztest_thread,

View File

@ -4159,7 +4159,7 @@ zpool_label_name(char *label_name, int label_size)
int fd; int fd;
fd = open("/dev/urandom", O_RDONLY); fd = open("/dev/urandom", O_RDONLY);
if (fd > 0) { if (fd >= 0) {
if (read(fd, &id, sizeof (id)) != sizeof (id)) if (read(fd, &id, sizeof (id)) != sizeof (id))
id = 0; id = 0;

View File

@ -108,6 +108,7 @@ main(int argc, char **argv)
} }
j++; j++;
} }
(void) close(fd);
} else if (pid == 0) { } else if (pid == 0) {
int fd = open(dirpath, O_RDONLY); int fd = open(dirpath, O_RDONLY);
int chownret; int chownret;
@ -128,6 +129,7 @@ main(int argc, char **argv)
k++; k++;
} }
(void) close(fd);
} }
return (0); return (0);