paride/pf: need to set queue to NULL before put_disk
authorzhengbin <zhengbin13@huawei.com>
Tue, 13 Aug 2019 08:59:44 +0000 (16:59 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 4 Sep 2019 13:00:33 +0000 (07:00 -0600)
In pf_init_units, if blk_mq_init_sq_queue fails, need to set queue to
NULL before put_disk, otherwise null-ptr-deref Read will occur.

put_disk
  kobject_put
    disk_release
      blk_put_queue(disk->queue)

Fixes: 77218ddf46d8 ("paride: convert pf to blk-mq")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/paride/pf.c

index 1e9c50a7256cd88d7c8910430cd54875889be854..6b7d4cab36874e5b38bd665a49de7a5427cc04b8 100644 (file)
@@ -300,8 +300,8 @@ static void __init pf_init_units(void)
                disk->queue = blk_mq_init_sq_queue(&pf->tag_set, &pf_mq_ops,
                                                        1, BLK_MQ_F_SHOULD_MERGE);
                if (IS_ERR(disk->queue)) {
-                       put_disk(disk);
                        disk->queue = NULL;
+                       put_disk(disk);
                        continue;
                }