diff options
author | Richard Yao <[email protected]> | 2022-09-23 19:55:26 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-23 16:55:26 -0700 |
commit | ebe1d0361671c80025d5be2c31131ed223115873 (patch) | |
tree | 04f6b7e5a3af21a543afe7d4afa4465908cd4a29 /tests | |
parent | 2a493a4c7127258b14c39e8c71a9d6f01167c5cd (diff) |
Fix userland resource leaks
Coverity caught these. With the exception of the file descriptor leak in
tests/zfs-tests/cmd/draid.c, they are all memory leaks.
Also, there is a piece of dead code in zfs_get_enclosure_sysfs_path().
We delete it as cleanup.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #13921
Diffstat (limited to 'tests')
-rw-r--r-- | tests/zfs-tests/cmd/btree_test.c | 2 | ||||
-rw-r--r-- | tests/zfs-tests/cmd/draid.c | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/tests/zfs-tests/cmd/btree_test.c b/tests/zfs-tests/cmd/btree_test.c index aaad4e47e..456a36f31 100644 --- a/tests/zfs-tests/cmd/btree_test.c +++ b/tests/zfs-tests/cmd/btree_test.c @@ -233,13 +233,13 @@ drain_tree(zfs_btree_t *bt, char *why) void *ret; u_longlong_t randval = random(); - node = malloc(sizeof (int_node_t)); if ((p = (uint64_t *)zfs_btree_find(bt, &randval, &bt_idx)) != NULL) { continue; } zfs_btree_add_idx(bt, &randval, &bt_idx); + node = malloc(sizeof (int_node_t)); node->data = randval; if ((ret = avl_find(&avl, node, &avl_idx)) != NULL) { snprintf(why, BUFSIZE, "Found in avl: %llu\n", randval); diff --git a/tests/zfs-tests/cmd/draid.c b/tests/zfs-tests/cmd/draid.c index 831039288..869ca902d 100644 --- a/tests/zfs-tests/cmd/draid.c +++ b/tests/zfs-tests/cmd/draid.c @@ -849,6 +849,7 @@ restart: if (rc < 0) { printf("Unable to read /dev/urandom: %s\n:", strerror(errno)); + close(fd); return (1); } bytes_read += rc; |