mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
Fix zfs_unmount() and zfs_unshare_proto() leaks
Always free mnpt memory on failure in the zfs_unmount() function. In the zfs_unshare_proto() function mountpoint is a const and should not be assigned. Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #5054
This commit is contained in:
parent
ee36c709c3
commit
2d96d7aa56
@ -564,8 +564,10 @@ zfs_unmount(zfs_handle_t *zhp, const char *mountpoint, int flags)
|
|||||||
/*
|
/*
|
||||||
* Unshare and unmount the filesystem
|
* Unshare and unmount the filesystem
|
||||||
*/
|
*/
|
||||||
if (zfs_unshare_proto(zhp, mntpt, share_all_proto) != 0)
|
if (zfs_unshare_proto(zhp, mntpt, share_all_proto) != 0) {
|
||||||
|
free(mntpt);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
if (unmount_one(hdl, mntpt, flags) != 0) {
|
if (unmount_one(hdl, mntpt, flags) != 0) {
|
||||||
free(mntpt);
|
free(mntpt);
|
||||||
@ -904,7 +906,7 @@ zfs_unshare_proto(zfs_handle_t *zhp, const char *mountpoint,
|
|||||||
|
|
||||||
/* check to see if need to unmount the filesystem */
|
/* check to see if need to unmount the filesystem */
|
||||||
if (mountpoint != NULL)
|
if (mountpoint != NULL)
|
||||||
mountpoint = mntpt = zfs_strdup(hdl, mountpoint);
|
mntpt = zfs_strdup(hdl, mountpoint);
|
||||||
|
|
||||||
if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) &&
|
if (mountpoint != NULL || ((zfs_get_type(zhp) == ZFS_TYPE_FILESYSTEM) &&
|
||||||
libzfs_mnttab_find(hdl, zfs_get_name(zhp), &entry) == 0)) {
|
libzfs_mnttab_find(hdl, zfs_get_name(zhp), &entry) == 0)) {
|
||||||
@ -918,7 +920,7 @@ zfs_unshare_proto(zfs_handle_t *zhp, const char *mountpoint,
|
|||||||
|
|
||||||
if (is_shared(hdl, mntpt, *curr_proto) &&
|
if (is_shared(hdl, mntpt, *curr_proto) &&
|
||||||
unshare_one(hdl, zhp->zfs_name,
|
unshare_one(hdl, zhp->zfs_name,
|
||||||
mntpt, *curr_proto) != 0) {
|
mntpt, *curr_proto) != 0) {
|
||||||
if (mntpt != NULL)
|
if (mntpt != NULL)
|
||||||
free(mntpt);
|
free(mntpt);
|
||||||
return (-1);
|
return (-1);
|
||||||
|
Loading…
Reference in New Issue
Block a user