From 270da570de744bf0323ae35efb22f4c46eb1026a Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Tue, 25 Sep 2012 17:00:44 +1000 Subject: [PATCH] md/raid5: add some missing locking in handle_failed_stripe. We really should hold the stripe_lock while accessing 'toread' else we could race with add_stripe_bio and corrupt a list. Reported-by: "Jianpeng Ma" Signed-off-by: NeilBrown --- drivers/md/raid5.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 576f796969a7..c09a1aaa0cb7 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -2593,8 +2593,10 @@ handle_failed_stripe(struct r5conf *conf, struct stripe_head *sh, if (!test_bit(R5_Wantfill, &sh->dev[i].flags) && (!test_bit(R5_Insync, &sh->dev[i].flags) || test_bit(R5_ReadError, &sh->dev[i].flags))) { + spin_lock_irq(&sh->stripe_lock); bi = sh->dev[i].toread; sh->dev[i].toread = NULL; + spin_unlock_irq(&sh->stripe_lock); if (test_and_clear_bit(R5_Overlap, &sh->dev[i].flags)) wake_up(&conf->wait_for_overlap); if (bi) s->to_read--; -- 2.39.5