summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNigel Croxon <ncroxon@redhat.com>2023-09-11 14:25:23 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-09-23 11:10:01 +0200
commitd30af15e460f7173ce40ff60663a3402068ee3d3 (patch)
tree2d029abaadf5e9ce144f8aafb16e1516061fde0c
parentabdfde0377124ed0e3821e52dd420432d3c645c7 (diff)
downloadlinux-d30af15e460f7173ce40ff60663a3402068ee3d3.tar.gz
linux-d30af15e460f7173ce40ff60663a3402068ee3d3.tar.bz2
linux-d30af15e460f7173ce40ff60663a3402068ee3d3.zip
md/raid1: fix error: ISO C90 forbids mixed declarations
[ Upstream commit df203da47f4428bc286fc99318936416253a321c ] There is a compile error when this commit is added: md: raid1: fix potential OOB in raid1_remove_disk() drivers/md/raid1.c: In function 'raid1_remove_disk': drivers/md/raid1.c:1844:9: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 1844 |         struct raid1_info *p = conf->mirrors + number;     |         ^~~~~~ That's because the new code was inserted before the struct. The change is move the struct command above this commit. Fixes: 8b0472b50bcf ("md: raid1: fix potential OOB in raid1_remove_disk()") Signed-off-by: Nigel Croxon <ncroxon@redhat.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/46d929d0-2aab-4cf2-b2bf-338963e8ba5a@redhat.com Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--drivers/md/raid1.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 5360d6ed16e0..8427c9767a61 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1820,12 +1820,11 @@ static int raid1_remove_disk(struct mddev *mddev, struct md_rdev *rdev)
struct r1conf *conf = mddev->private;
int err = 0;
int number = rdev->raid_disk;
+ struct raid1_info *p = conf->mirrors + number;
if (unlikely(number >= conf->raid_disks))
goto abort;
- struct raid1_info *p = conf->mirrors + number;
-
if (rdev != p->rdev)
p = conf->mirrors + conf->raid_disks + number;