Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1331952 > unrolled thread

[PATCH] null_blk: oops when initializing without lightnvm

Started byMatias Bjørling <m@bjorling.me>
First post2016-02-11 14:50 +0100
Last post2016-02-11 17:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] null_blk: oops when initializing without lightnvm Matias Bjørling <m@bjorling.me> - 2016-02-11 14:50 +0100
    Re: [PATCH] null_blk: oops when initializing without lightnvm Jens Axboe <axboe@kernel.dk> - 2016-02-11 17:00 +0100

#1331952 — [PATCH] null_blk: oops when initializing without lightnvm

FromMatias Bjørling <m@bjorling.me>
Date2016-02-11 14:50 +0100
Subject[PATCH] null_blk: oops when initializing without lightnvm
Message-ID<r0ZN8-13S-7@gated-at.bofh.it>
If the LightNVM subsystem is not compiled into the kernel, and the
null_blk device driver requests lightnvm to be initialized. The call to
nvm_register fails and the null_add_dev function cleans up the
initialization. However, at this point the null block device has
already been added to the nullb_list and thus a second cleanup will
occur when the function has returned, that leads to a double call to
blk_cleanup_queue.

Signed-off-by: Matias Bjørling <m@bjorling.me>
---
 drivers/block/null_blk.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index ae05d31..64a7b59 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -707,9 +707,7 @@ static int null_add_dev(void)
 	queue_flag_set_unlocked(QUEUE_FLAG_NONROT, nullb->q);
 	queue_flag_clear_unlocked(QUEUE_FLAG_ADD_RANDOM, nullb->q);
 
-
 	mutex_lock(&lock);
-	list_add_tail(&nullb->list, &nullb_list);
 	nullb->index = nullb_indexes++;
 	mutex_unlock(&lock);
 
@@ -743,6 +741,10 @@ static int null_add_dev(void)
 	strncpy(disk->disk_name, nullb->disk_name, DISK_NAME_LEN);
 
 	add_disk(disk);
+
+	mutex_lock(&lock);
+	list_add_tail(&nullb->list, &nullb_list);
+	mutex_unlock(&lock);
 done:
 	return 0;
 
-- 
2.1.4

[toc] | [next] | [standalone]


#1332176

FromJens Axboe <axboe@kernel.dk>
Date2016-02-11 17:00 +0100
Message-ID<r11OW-2po-9@gated-at.bofh.it>
In reply to#1331952
On 02/11/2016 06:49 AM, Matias Bjørling wrote:
> If the LightNVM subsystem is not compiled into the kernel, and the
> null_blk device driver requests lightnvm to be initialized. The call to
> nvm_register fails and the null_add_dev function cleans up the
> initialization. However, at this point the null block device has
> already been added to the nullb_list and thus a second cleanup will
> occur when the function has returned, that leads to a double call to
> blk_cleanup_queue.

Deferring the add seems fine, applied for 4.5.

-- 
Jens Axboe

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web