Skip to content

Commit fed13a5

Browse files
author
Mikulas Patocka
committed
dm: fix a crash if blk_alloc_disk fails
If blk_alloc_disk fails, the variable md->disk is set to an error value. cleanup_mapped_device will see that md->disk is non-NULL and it will attempt to access it, causing a crash on this statement "md->disk->private_data = NULL;". Signed-off-by: Mikulas Patocka <[email protected]> Reported-by: Chenyuan Yang <[email protected]> Closes: https://marc.info/?l=dm-devel&m=172824125004329&w=2 Cc: [email protected] Reviewed-by: Nitesh Shetty <[email protected]>
1 parent 8e929cb commit fed13a5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/md/dm.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2290,8 +2290,10 @@ static struct mapped_device *alloc_dev(int minor)
22902290
* override accordingly.
22912291
*/
22922292
md->disk = blk_alloc_disk(NULL, md->numa_node_id);
2293-
if (IS_ERR(md->disk))
2293+
if (IS_ERR(md->disk)) {
2294+
md->disk = NULL;
22942295
goto bad;
2296+
}
22952297
md->queue = md->disk->queue;
22962298

22972299
init_waitqueue_head(&md->wait);

0 commit comments

Comments
 (0)