]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
dm-raid: fix possible NULL dereference with undefined raid type
authorAlexey Simakov <bigalex934@gmail.com>
Tue, 2 Dec 2025 17:18:38 +0000 (20:18 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:09:39 +0000 (13:09 +0100)
commit8d656002fa38ad6bacfbfd91d8696e9bb6277aff
tree05e5117c6193e3c4e0d8bf72505fd78e21010f56
parenta9bfe4eb0103abaebb6a2a806844b0084b3537a1
dm-raid: fix possible NULL dereference with undefined raid type

[ Upstream commit 2f6cfd6d7cb165a7af8877b838a9f6aab4159324 ]

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: 33e53f06850f ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/md/dm-raid.c