OSDN Git Service

paride/pcd: need to set queue to NULL before put_disk
authorzhengbin <zhengbin13@huawei.com>
Tue, 13 Aug 2019 11:27:40 +0000 (19:27 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 4 Sep 2019 13:01:02 +0000 (07:01 -0600)
In pcd_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: f0d176255401 ("paride/pcd: Fix potential NULL pointer dereference and mem leak")
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/pcd.c

index 001dbdc..bfca80d 100644 (file)
@@ -314,8 +314,8 @@ static void pcd_init_units(void)
                disk->queue = blk_mq_init_sq_queue(&cd->tag_set, &pcd_mq_ops,
                                                   1, BLK_MQ_F_SHOULD_MERGE);
                if (IS_ERR(disk->queue)) {
-                       put_disk(disk);
                        disk->queue = NULL;
+                       put_disk(disk);
                        continue;
                }