summaryrefslogtreecommitdiffstats
path: root/module/zfs/zvol.c
diff options
context:
space:
mode:
authorLOLi <[email protected]>2017-05-31 21:52:12 +0200
committerBrian Behlendorf <[email protected]>2017-05-31 12:52:12 -0700
commit3f7d0418dc663e3a968cf0b28b45f6ef5b83bb06 (patch)
tree5f350ee526bb70c10c243b89ca3f993bca528ff1 /module/zfs/zvol.c
parent434c76ca91e9def899355914473a03441697b896 (diff)
Fix memory leak in zvol_set_volsize()
Move kmem_free() so it's called for every error path: this is preferred over making `dmu_object_info_t doi` local to accommodate older kernels with limited stacks. Reviewed by: Boris Protopopov <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #6177
Diffstat (limited to 'module/zfs/zvol.c')
-rw-r--r--module/zfs/zvol.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/module/zfs/zvol.c b/module/zfs/zvol.c
index 8ca510b79..cff3da8b4 100644
--- a/module/zfs/zvol.c
+++ b/module/zfs/zvol.c
@@ -419,11 +419,12 @@ zvol_set_volsize(const char *name, uint64_t volsize)
goto out;
error = zvol_update_volsize(volsize, os);
- kmem_free(doi, sizeof (dmu_object_info_t));
if (error == 0 && zv != NULL)
error = zvol_update_live_volsize(zv, volsize);
out:
+ kmem_free(doi, sizeof (dmu_object_info_t));
+
if (owned) {
dmu_objset_disown(os, FTAG);
if (zv != NULL)