summaryrefslogtreecommitdiff
path: root/drivers/lightnvm/core.c
diff options
context:
space:
mode:
authorJavier González <jg@lightnvm.io>2017-04-15 21:55:43 +0300
committerJens Axboe <axboe@fb.com>2017-04-16 19:06:25 +0300
commit7d1ef2f408abecc05f9dfaec1095098a090879dc (patch)
treef27c6b044f8c1abe71be1a19ffe817b9080e3f24 /drivers/lightnvm/core.c
parentedee1bdd66bf0fda46a176bc3ee5c992dbbc466e (diff)
downloadlinux-7d1ef2f408abecc05f9dfaec1095098a090879dc.tar.xz
lightnvm: fix cleanup order of disk on init error
Reorder disk allocation such that the disk structure can be put safely. Signed-off-by: Javier González <javier@cnexlabs.com> Signed-off-by: Matias Bjørling <matias@cnexlabs.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/lightnvm/core.c')
-rw-r--r--drivers/lightnvm/core.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c
index 5eea3d5ecc30..5f84d2a418f6 100644
--- a/drivers/lightnvm/core.c
+++ b/drivers/lightnvm/core.c
@@ -264,15 +264,15 @@ static int nvm_create_tgt(struct nvm_dev *dev, struct nvm_ioctl_create *create)
goto err_t;
}
+ tdisk = alloc_disk(0);
+ if (!tdisk)
+ goto err_dev;
+
tqueue = blk_alloc_queue_node(GFP_KERNEL, dev->q->node);
if (!tqueue)
- goto err_dev;
+ goto err_disk;
blk_queue_make_request(tqueue, tt->make_rq);
- tdisk = alloc_disk(0);
- if (!tdisk)
- goto err_queue;
-
sprintf(tdisk->disk_name, "%s", create->tgtname);
tdisk->flags = GENHD_FL_EXT_DEVT;
tdisk->major = 0;
@@ -308,9 +308,9 @@ err_sysfs:
if (tt->exit)
tt->exit(targetdata);
err_init:
- put_disk(tdisk);
-err_queue:
blk_cleanup_queue(tqueue);
+err_disk:
+ put_disk(tdisk);
err_dev:
nvm_remove_tgt_dev(tgt_dev, 0);
err_t: