Skip to content

Commit 2f6cfd6

Browse files
jtstrsMikulas Patocka
authored andcommitted
dm-raid: fix possible NULL dereference with undefined raid type
rs->raid_type is assigned from get_raid_type_by_ll(), which may return NULL. This NULL value could be dereferenced later in the condition 'if (!(rs_is_raid10(rs) && rt_is_raid0(rs->raid_type)))'. Add a fail-fast check to return early with an error if raid_type is NULL, similar to other uses of this function. Found by Linux Verification Center (linuxtesting.org) with Svace. Fixes: 33e53f0 ("dm raid: introduce extended superblock and new raid types to support takeover/reshaping") Signed-off-by: Alexey Simakov <bigalex934@gmail.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
1 parent 8581b19 commit 2f6cfd6

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

drivers/md/dm-raid.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,6 +2287,8 @@ static int super_init_validation(struct raid_set *rs, struct md_rdev *rdev)
22872287

22882288
mddev->reshape_position = le64_to_cpu(sb->reshape_position);
22892289
rs->raid_type = get_raid_type_by_ll(mddev->level, mddev->layout);
2290+
if (!rs->raid_type)
2291+
return -EINVAL;
22902292
}
22912293

22922294
} else {

0 commit comments

Comments
 (0)