Skip to content

Commit

Permalink
md/md-multipath: guard against a possible NULL dereference
Browse files Browse the repository at this point in the history
mempool_alloc might fail to allocate a slot, in which case we will end
up dereferencing a NULL mp_bh pointer.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.

Fixes: 1da177e ("Linux-2.6.12-rc2")
Signed-off-by: Daniil Tatianin <d-tatianin@yandex-team.ru>
  • Loading branch information
d-tatianin authored and intel-lab-lkp committed Apr 20, 2023
1 parent 7bc4361 commit 3b0e378
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/md/md-multipath.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ static bool multipath_make_request(struct mddev *mddev, struct bio * bio)
return true;

mp_bh = mempool_alloc(&conf->pool, GFP_NOIO);
if (!map_bh)
return false;

mp_bh->master_bio = bio;
mp_bh->mddev = mddev;
Expand Down

0 comments on commit 3b0e378

Please sign in to comment.