]> granicus.if.org Git - zfs/commitdiff
Fix NULL deref when zvol_alloc() fails
authorBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 27 Nov 2012 22:02:49 +0000 (14:02 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 27 Nov 2012 22:10:31 +0000 (14:10 -0800)
If zvol_alloc() fails zv will be set to NULL and dereferenced
in out_dmu_objset_disown.  To avoid this entirely the zv->objset
line is moved up in to the success block.

Original-patch-by: Jorgen Lundman <lundman@lundman.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #1109

module/zfs/zvol.c

index c3bd25c3b610be4ea1a63f7ade350fa51bbedc12..5d4802560201cb839ac662a8927d6380f8958b0c 100644 (file)
@@ -1306,9 +1306,9 @@ __zvol_create_minor(const char *name)
        else
                zil_replay(os, zv, zvol_replay_vector);
 
+       zv->zv_objset = NULL;
 out_dmu_objset_disown:
        dmu_objset_disown(os, zvol_tag);
-       zv->zv_objset = NULL;
 out_doi:
        kmem_free(doi, sizeof(dmu_object_info_t));
 out: