Skip to content

Commit 46f2195

Browse files
committed
md/raid0: fix NULL pointer dereference in create_strip_zones() for dm-raid
Commit 2107457 ("md/raid0: Move queue limit setup before r0conf initialization") dereference mddev->gendisk unconditionally, which is NULL for dm-raid. Fix this problem by reverting to old codes for dm-raid. Link: https://lore.kernel.org/linux-raid/20251116021816.107648-1-yukuai@fnnas.com Fixes: 2107457 ("md/raid0: Move queue limit setup before r0conf initialization") Reported-and-tested-by: Changhui Zhong <czhong@redhat.com> Closes: https://lore.kernel.org/all/CAGVVp+VqVnvGeneUoTbYvBv2cw6GwQRrR3B-iQ-_9rVfyumoKA@mail.gmail.com/ Signed-off-by: Yu Kuai <yukuai@fnnas.com> Reviewed-by: Xiao Ni <xni@redhat.com> Reviewed-by: Li Nan <linan122@huawei.com> Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de>
1 parent 418de94 commit 46f2195

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

drivers/md/raid0.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
6868
struct strip_zone *zone;
6969
int cnt;
7070
struct r0conf *conf = kzalloc(sizeof(*conf), GFP_KERNEL);
71-
unsigned int blksize = queue_logical_block_size(mddev->gendisk->queue);
71+
unsigned int blksize = 512;
72+
73+
if (!mddev_is_dm(mddev))
74+
blksize = queue_logical_block_size(mddev->gendisk->queue);
7275

7376
*private_conf = ERR_PTR(-ENOMEM);
7477
if (!conf)
@@ -84,6 +87,10 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
8487
sector_div(sectors, mddev->chunk_sectors);
8588
rdev1->sectors = sectors * mddev->chunk_sectors;
8689

90+
if (mddev_is_dm(mddev))
91+
blksize = max(blksize, queue_logical_block_size(
92+
rdev1->bdev->bd_disk->queue));
93+
8794
rdev_for_each(rdev2, mddev) {
8895
pr_debug("md/raid0:%s: comparing %pg(%llu)"
8996
" with %pg(%llu)\n",

0 commit comments

Comments
 (0)