Message ID | 16e9030d-e55c-47eb-1a2a-dff8a50e6627@redhat.com (mailing list archive) |
---|---|
State | Accepted, archived |
Delegated to: | Mikulas Patocka |
Headers | show |
Series | dm: fix a crash if blk_alloc_disk fails | expand |
On 07/10/24 01:38PM, Mikulas Patocka wrote: > >Hi > >Here I'm submitting a patch for this bug. > >Mikulas > > >From: Mikulas Patocka <mpatocka@redhat.com> > >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 <mpatocka@redhat.com> >Reported-by: Chenyuan Yang <chenyuan0y@gmail.com> >Closes: https://marc.info/?l=dm-devel&m=172824125004329&w=2 >Cc: stable@vger.kernel.org Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Index: linux-2.6/drivers/md/dm.c =================================================================== --- linux-2.6.orig/drivers/md/dm.c 2024-09-30 16:40:54.000000000 +0200 +++ linux-2.6/drivers/md/dm.c 2024-10-07 13:23:40.000000000 +0200 @@ -2290,8 +2290,10 @@ static struct mapped_device *alloc_dev(i * 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);