]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
md/raid5: don't index beyond end of array in need_this_block().
authorNeilBrown <neilb@suse.com>
Thu, 24 Sep 2015 05:25:36 +0000 (15:25 +1000)
committerFred Herard <fred.herard@oracle.com>
Thu, 15 Jun 2017 01:57:58 +0000 (21:57 -0400)
When need_this_block probably shouldn't be called when there
are more than 2 failed devices, we really don't want it to try
indexing beyond the end of the failed_num[] of fdev[] arrays.

So limit the loops to at most 2 iterations.

Reported-by: Shaohua Li <shli@fb.com>
Signed-off-by: NeilBrown <neilb@suse.de>
(cherry picked from commit 36707bb2e7c6730d79d6cdc6d1475d3d7e94c518)
Orabug: 26047272
Signed-off-by: Fred Herard <fred.herard@oracle.com>
Reviewed-by: John Sobecki <john.sobecki@oracle.com>
drivers/md/raid5.c

index ef0a99a3a77927c357d02574a48a6a35de85f416..71ecfad9a47677fb86aebea3b268fea0eff8eff6 100644 (file)
@@ -3309,7 +3309,7 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s,
                 */
                return 0;
 
-       for (i = 0; i < s->failed; i++) {
+       for (i = 0; i < s->failed && i < 2; i++) {
                if (fdev[i]->towrite &&
                    !test_bit(R5_UPTODATE, &fdev[i]->flags) &&
                    !test_bit(R5_OVERWRITE, &fdev[i]->flags))
@@ -3333,7 +3333,7 @@ static int need_this_block(struct stripe_head *sh, struct stripe_head_state *s,
            sh->sector < sh->raid_conf->mddev->recovery_cp)
                /* reconstruct-write isn't being forced */
                return 0;
-       for (i = 0; i < s->failed; i++) {
+       for (i = 0; i < s->failed && i < 2; i++) {
                if (s->failed_num[i] != sh->pd_idx &&
                    s->failed_num[i] != sh->qd_idx &&
                    !test_bit(R5_UPTODATE, &fdev[i]->flags) &&