aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikulas Patocka <[email protected]>2024-10-07 13:38:12 +0200
committerMikulas Patocka <[email protected]>2024-10-15 13:37:17 +0200
commitfed13a5478680614ba97fc87e71f16e2e197912e (patch)
tree69e5f716fe994c8cc26e8f843c4a6abef4216c76
parent8e929cb546ee42c9a61d24fae60605e9e3192354 (diff)
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]>
-rw-r--r--drivers/md/dm.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index ff4a6b570b76..19230404d8c2 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2290,8 +2290,10 @@ static struct mapped_device *alloc_dev(int minor)
* override accordingly.
*/
md->disk = blk_alloc_disk(NULL, md->numa_node_id);
- if (IS_ERR(md->disk))
+ if (IS_ERR(md->disk)) {
+ md->disk = NULL;
goto bad;
+ }
md->queue = md->disk->queue;
init_waitqueue_head(&md->wait);