HomeFreeBSD

Fix userspace memory leaks found by Clang Static Analzyer

Description

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 <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13955

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Sep 27 2022, 12:18 AM
GitHub <noreply@github.com>Committed on Sep 27 2022, 12:18 AM
Parents
rG5e7a2f4665b5: Update zfs-mount to load before fstab, matches systemd service.
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rGf7bda2de9786: Fix userspace memory leaks found by Clang Static Analzyer (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Sep 27 2022, 12:18 AM