Skip to content

Commit 8364da4

Browse files
Josef Bacikaxboe
authored andcommitted
nbd: fix nbd device deletion
This fixes a use after free bug, we shouldn't be doing disk->queue right after we do del_gendisk(disk). Save the queue and do the cleanup after the del_gendisk. Fixes: c6a4759 ("nbd: add device refcounting") cc: [email protected] Signed-off-by: Josef Bacik <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 3de9bee commit 8364da4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

drivers/block/nbd.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,12 @@ static const struct device_attribute pid_attr = {
173173
static void nbd_dev_remove(struct nbd_device *nbd)
174174
{
175175
struct gendisk *disk = nbd->disk;
176+
struct request_queue *q;
177+
176178
if (disk) {
179+
q = disk->queue;
177180
del_gendisk(disk);
178-
blk_cleanup_queue(disk->queue);
181+
blk_cleanup_queue(q);
179182
blk_mq_free_tag_set(&nbd->tag_set);
180183
disk->private_data = NULL;
181184
put_disk(disk);

0 commit comments

Comments
 (0)