2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-11-27 20:13:57 +08:00

null_blk: Fix null pointer dereference on nullb->disk on blk_cleanup_disk call

The error handling on a nullb->disk allocation currently jumps to
out_cleanup_disk that calls blk_cleanup_disk with a null pointer causing
a null pointer dereference issue. Fix this by jumping to out_cleanup_tags
instead.

Addresses-Coverity: ("Dereference after null check")
Fixes: 132226b301 ("null_blk: convert to blk_alloc_disk/blk_cleanup_disk")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210602100659.11058-1-colin.king@canonical.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Colin Ian King 2021-06-02 11:06:59 +01:00 committed by Jens Axboe
parent 0e0ccdecb3
commit 90bf3e28ef

View File

@ -1856,7 +1856,7 @@ static int null_add_dev(struct nullb_device *dev)
goto out_cleanup_tags;
nullb->disk = alloc_disk_node(1, nullb->dev->home_node);
if (!nullb->disk)
goto out_cleanup_disk;
goto out_cleanup_tags;
nullb->disk->queue = nullb->q;
} else if (dev->queue_mode == NULL_Q_BIO) {
rv = -ENOMEM;