diff options
author | Richard Yao <[email protected]> | 2022-09-26 20:18:05 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2022-09-26 17:18:05 -0700 |
commit | f7bda2de9786017348fd814603735f2be4182825 (patch) | |
tree | f24898dc331701ab3974068d4d2735d17f5bb35e /contrib | |
parent | 5e7a2f4665b5be32dab9c183e6fdb94e1f434b70 (diff) |
Fix userspace memory leaks found by Clang Static Analzyer
Recently, I have been making a push to fix things that coverity found.
However, I was curious what Clang's static analyzer reported, so I ran
it and found things that coverity had missed.
* contrib/pam_zfs_key/pam_zfs_key.c: If prop_mountpoint is passed more
than once, we leak memory.
* module/zfs/zcp_get.c: We leak memory on temporary properties in
userspace.
* tests/zfs-tests/cmd/draid.c: On error from vdev_draid_rand(), we leak
memory if best_map had been allocated by a prior iteration.
* tests/zfs-tests/cmd/mkfile.c: Memory used by the loop is not freed
before program termination.
Arguably, these are all minor issues, but if we ignore them, then they
could obscure serious bugs, so we fix them.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #13955
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/pam_zfs_key/pam_zfs_key.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/contrib/pam_zfs_key/pam_zfs_key.c b/contrib/pam_zfs_key/pam_zfs_key.c index c1001e6b8..aaca67008 100644 --- a/contrib/pam_zfs_key/pam_zfs_key.c +++ b/contrib/pam_zfs_key/pam_zfs_key.c @@ -480,7 +480,8 @@ zfs_key_config_load(pam_handle_t *pamh, zfs_key_config_t *config, } else if (strcmp(argv[c], "nounmount") == 0) { config->unmount_and_unload = 0; } else if (strcmp(argv[c], "prop_mountpoint") == 0) { - config->homedir = strdup(entry->pw_dir); + if (config->homedir == NULL) + config->homedir = strdup(entry->pw_dir); } } return (0); |