Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zmo leak when zfs_sb_create fails #5496

Merged
merged 1 commit into from
Dec 19, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions module/zfs/zfs_vfsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -744,19 +744,17 @@ zfs_sb_create(const char *osname, zfs_mntopts_t *zmo, zfs_sb_t **zsbp)
zsb = kmem_zalloc(sizeof (zfs_sb_t), KM_SLEEP);

/*
* We claim to always be readonly so we can open snapshots;
* other ZPL code will prevent us from writing to snapshots.
* Optional temporary mount options, free'd in zfs_sb_free().
*/
error = dmu_objset_own(osname, DMU_OST_ZFS, B_TRUE, zsb, &os);
if (error) {
kmem_free(zsb, sizeof (zfs_sb_t));
return (error);
}
zsb->z_mntopts = (zmo ? zmo : zfs_mntopts_alloc());

/*
* Optional temporary mount options, free'd in zfs_sb_free().
* We claim to always be readonly so we can open snapshots;
* other ZPL code will prevent us from writing to snapshots.
*/
zsb->z_mntopts = (zmo ? zmo : zfs_mntopts_alloc());
error = dmu_objset_own(osname, DMU_OST_ZFS, B_TRUE, zsb, &os);
if (error)
goto out_zmo;

/*
* Initialize the zfs-specific filesystem structure.
Expand Down Expand Up @@ -896,8 +894,9 @@ zfs_sb_create(const char *osname, zfs_mntopts_t *zmo, zfs_sb_t **zsbp)

out:
dmu_objset_disown(os, zsb);
out_zmo:
*zsbp = NULL;

zfs_mntopts_free(zsb->z_mntopts);
kmem_free(zsb, sizeof (zfs_sb_t));
return (error);
}
Expand Down