libzfs: zfs_userns: Don't leak the namespace fd

zfs_userns opens a file descriptor for the kernel to look up a
namespace, but does not close it.

Close the fd when we're done with it.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Ryan Moeller <freqlabs@FreeBSD.org>
Closes #13554
This commit is contained in:
Ryan Moeller 2022-06-13 20:24:23 +00:00 committed by Brian Behlendorf
parent 482505fd42
commit def1a401f4
1 changed files with 2 additions and 0 deletions

View File

@ -274,5 +274,7 @@ zfs_userns(zfs_handle_t *zhp, const char *nspath, int attach)
if ((ret = zfs_ioctl(hdl, cmd, &zc)) != 0) if ((ret = zfs_ioctl(hdl, cmd, &zc)) != 0)
zfs_standard_error(hdl, errno, errbuf); zfs_standard_error(hdl, errno, errbuf);
(void) close(zc.zc_cleanup_fd);
return (ret); return (ret);
} }