]> granicus.if.org Git - zfs/commitdiff
Fix ida leak in zvol_create_minor_impl
authorBoris Protopopov <bprotopopov@users.noreply.github.com>
Sat, 27 May 2017 00:50:25 +0000 (20:50 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sat, 27 May 2017 00:50:25 +0000 (17:50 -0700)
Added missing ida_simple_remove() in the error handling path.

Reviewed-by: Chunwei Chen <david.chen@osnexus.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Boris Protopopov <boris.protopopov@actifio.com>
Closes #6159
Closes #6172

module/zfs/zvol.c

index 121f75e4e257de77e5e637cb64dc062104446a70..8ca510b794efc8d90c3720a02e3258a6e018a9bb 100644 (file)
@@ -1164,6 +1164,12 @@ zvol_resume(zvol_state_t *zv)
        int error = 0;
 
        ASSERT(RW_WRITE_HELD(&zv->zv_suspend_lock));
+
+       /*
+        * Cannot take zv_state_lock here with zv_suspend_lock
+        * held; however, the latter is held in exclusive mode,
+        * so it is not necessary to do so
+        */
        if (zv->zv_open_count > 0) {
                VERIFY0(dmu_objset_hold(zv->zv_name, zv, &zv->zv_objset));
                VERIFY3P(zv->zv_objset->os_dsl_dataset->ds_owner, ==, zv);
@@ -1620,6 +1626,7 @@ zvol_create_minor_impl(const char *name)
        zv = zvol_find_by_name_hash(name, hash);
        if (zv) {
                mutex_exit(&zvol_state_lock);
+               ida_simple_remove(&zvol_ida, idx);
                return (SET_ERROR(EEXIST));
        }