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 <bprotopopov@hotmail.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #6177
This commit is contained in:
LOLi 2017-05-31 21:52:12 +02:00 committed by Brian Behlendorf
parent 434c76ca91
commit 3f7d0418dc
1 changed files with 2 additions and 1 deletions

View File

@ -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)