@@ -1810,6 +1810,7 @@ static void null_del_dev(struct nullb *nullb)
return;
dev = nullb->dev;
+ dev->nullb = NULL;
ida_simple_remove(&nullb_indexes, nullb->index);
@@ -1831,7 +1832,6 @@ static void null_del_dev(struct nullb *nullb)
if (null_cache_active(nullb))
null_free_device_storage(nullb->dev, true);
kfree(nullb);
- dev->nullb = NULL;
}
static void null_config_discard(struct nullb *nullb)
@@ -2087,7 +2087,6 @@ static int null_add_dev(struct nullb_device *dev)
goto out;
}
nullb->dev = dev;
- dev->nullb = nullb;
spin_lock_init(&nullb->lock);
@@ -2179,6 +2178,7 @@ static int null_add_dev(struct nullb_device *dev)
if (rv)
goto out_ida_free;
+ dev->nullb = nullb;
mutex_lock(&lock);
list_add_tail(&nullb->list, &nullb_list);
mutex_unlock(&lock);
@@ -2200,7 +2200,6 @@ static int null_add_dev(struct nullb_device *dev)
cleanup_queues(nullb);
out_free_nullb:
kfree(nullb);
- dev->nullb = NULL;
out:
return rv;
}