From: NeilBrown Date: Tue, 25 Sep 2012 07:00:44 +0000 (+1000) Subject: md/raid5: add some missing locking in handle_failed_stripe. X-Git-Tag: next-20120926~52^2~3 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=270da570de744bf0323ae35efb22f4c46eb1026a;p=karo-tx-linux.git 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 --- 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--;