Skip to content

Commit

Permalink
lightnvm: prematurely activate nvm_dev
Browse files Browse the repository at this point in the history
We register with nvm_devices when there registration can still fail.
Move the final registration at the end of the nvm_register function
to make sure we are fully registered when added to the nvm_devices list.

Signed-off-by: Matias Bjørling <m@bjorling.me>
Signed-off-by: Jens Axboe <axboe@fb.com>
  • Loading branch information
Matias Bjørling authored and Jens Axboe committed Nov 16, 2015
1 parent 4264c98 commit edad2e6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/lightnvm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,6 @@ int nvm_register(struct request_queue *q, char *disk_name,
if (ret)
goto err_init;

down_write(&nvm_lock);
list_add(&dev->devices, &nvm_devices);
up_write(&nvm_lock);

if (dev->ops->max_phys_sect > 1) {
dev->ppalist_pool = dev->ops->create_dma_pool(dev->q,
"ppalist");
Expand All @@ -334,6 +330,10 @@ int nvm_register(struct request_queue *q, char *disk_name,
return -EINVAL;
}

down_write(&nvm_lock);
list_add(&dev->devices, &nvm_devices);
up_write(&nvm_lock);

return 0;
err_init:
kfree(dev);
Expand Down

0 comments on commit edad2e6

Please sign in to comment.