Skip to content

Commit 1042124

Browse files
Wentao-Liangaxboe
authored andcommitted
drivers:md:fix a potential use-after-free bug
In line 2884, "raid5_release_stripe(sh);" drops the reference to sh and may cause sh to be released. However, sh is subsequently used in lines 2886 "if (sh->batch_head && sh != sh->batch_head)". This may result in an use-after-free bug. It can be fixed by moving "raid5_release_stripe(sh);" to the bottom of the function. Signed-off-by: Wentao_Liang <[email protected]> Signed-off-by: Song Liu <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 20313b1 commit 1042124

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/md/raid5.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2952,10 +2952,10 @@ static void raid5_end_write_request(struct bio *bi)
29522952
if (!test_and_clear_bit(R5_DOUBLE_LOCKED, &sh->dev[i].flags))
29532953
clear_bit(R5_LOCKED, &sh->dev[i].flags);
29542954
set_bit(STRIPE_HANDLE, &sh->state);
2955-
raid5_release_stripe(sh);
29562955

29572956
if (sh->batch_head && sh != sh->batch_head)
29582957
raid5_release_stripe(sh->batch_head);
2958+
raid5_release_stripe(sh);
29592959
}
29602960

29612961
static void raid5_error(struct mddev *mddev, struct md_rdev *rdev)

0 commit comments

Comments
 (0)