Skip to contentSkip to conversation

mtd_blkdevs: initialze new->rq in add_mtd_blktrans_dev

PATCH In review Christoph Hellwig 2 participants 3 messages Jun 16, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 mtd_blkdevs: initialze new->rq in add_mtd_blktrans_dev

Various places expect the request_queue in ->rq. Initialize it to avoid NULL pointer derefences.

Fixes 6966bb921def ("mtd_blkdevs: use blk_mq_alloc_disk")
---
 drivers/mtd/mtd_blkdevs.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mtd/mtd_blkdevs.c +1 -0
index 5dc4c966ea73..6ce4bc57f919 100644
@@ -382,6 +382,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)
 	}
 
 	new->disk = gd;
+	new->rq = new->disk->queue;
 	gd->private_data = new;
 	gd->major = tr->major;
 	gd->first_minor = (new->devnum) << tr->part_bits;
Signature · 1 line
2.30.2
#1 lore raw

PATCH 2/2 loop: fix order of cleaning up the queue and freeing the tagset

We must release the queue before freeing the tagset.

Fixes 1c99502fae35 ("loop: use blk_mq_alloc_disk and blk_cleanup_disk")
---
 drivers/block/loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/loop.c +1 -1
index 9a48b3f9a15c..e0c4de392eab 100644
@@ -2172,8 +2172,8 @@ static int loop_add(struct loop_device **l, int i)
 static void loop_remove(struct loop_device *lo)
 {
 	del_gendisk(lo->lo_disk);
-	blk_mq_free_tag_set(&lo->tag_set);
 	blk_cleanup_disk(lo->lo_disk);
+	blk_mq_free_tag_set(&lo->tag_set);
 	mutex_destroy(&lo->lo_mutex);
 	kfree(lo);
 }
Signature · 1 line
2.30.2
maintainer
#2 lore raw
In reply to Christoph Hellwig
Quoted 2 lines · Christoph Hellwig

Various places expect the request_queue in ->rq. Initialize it to avoid NULL pointer derefences.

Applied 1-2, thanks.

Signature · 1 line
Jens Axboe