zvol_os: Don't leak doi in cdev error path

Make sure to free doi in zvol_create_minor impl when make_dev_s fails.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Matt Macy <mmacy@FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #11117
This commit is contained in:
Ryan Moeller 2020-10-21 18:05:18 +00:00 committed by Brian Behlendorf
parent 9a0ef216e5
commit 277884ab42
1 changed files with 1 additions and 2 deletions

View File

@ -1328,7 +1328,7 @@ zvol_create_minor_impl(const char *name)
mutex_destroy(&zv->zv_state_lock); mutex_destroy(&zv->zv_state_lock);
kmem_free(zv, sizeof (*zv)); kmem_free(zv, sizeof (*zv));
dmu_objset_disown(os, B_TRUE, FTAG); dmu_objset_disown(os, B_TRUE, FTAG);
goto out_giant; goto out_doi;
} }
dev->si_iosize_max = MAXPHYS; dev->si_iosize_max = MAXPHYS;
zsd->zsd_cdev = dev; zsd->zsd_cdev = dev;
@ -1372,7 +1372,6 @@ out_doi:
rw_exit(&zvol_state_lock); rw_exit(&zvol_state_lock);
ZFS_LOG(1, "ZVOL %s created.", name); ZFS_LOG(1, "ZVOL %s created.", name);
} }
out_giant:
PICKUP_GIANT(); PICKUP_GIANT();
return (error); return (error);
} }