linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] raid1: fix error: ISO C90 forbids mixed declarations
@ 2023-09-09 11:53 Nigel Croxon
  2023-09-11 21:42 ` Song Liu
  0 siblings, 1 reply; 2+ messages in thread
From: Nigel Croxon @ 2023-09-09 11:53 UTC (permalink / raw)
  To: song, yukuai1, Zhang Shurong; +Cc: linux-raid, linux-kernel, yukuai3

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: md: raid1: fix potential OOB in raid1_remove_disk()
commit 8b0472b50bcf

Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
---
  drivers/md/raid1.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index a5453b126aab..4f1483bb708b 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1846,11 +1846,11 @@ static int raid1_remove_disk(struct mddev 
*mddev, struct md_rdev *rdev)
      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;

-- 
2.31.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] raid1: fix error: ISO C90 forbids mixed declarations
  2023-09-09 11:53 [PATCH] raid1: fix error: ISO C90 forbids mixed declarations Nigel Croxon
@ 2023-09-11 21:42 ` Song Liu
  0 siblings, 0 replies; 2+ messages in thread
From: Song Liu @ 2023-09-11 21:42 UTC (permalink / raw)
  To: Nigel Croxon; +Cc: yukuai1, Zhang Shurong, linux-raid, linux-kernel, yukuai3

On Sat, Sep 9, 2023 at 4:53 AM Nigel Croxon <ncroxon@redhat.com> wrote:
>
> 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: md: raid1: fix potential OOB in raid1_remove_disk()
> commit 8b0472b50bcf
>
> Signed-off-by: Nigel Croxon <ncroxon@redhat.com>

Applied to md-fixes after some minor fixes.

Thanks,
Song

> ---
>   drivers/md/raid1.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
> index a5453b126aab..4f1483bb708b 100644
> --- a/drivers/md/raid1.c
> +++ b/drivers/md/raid1.c
> @@ -1846,11 +1846,11 @@ static int raid1_remove_disk(struct mddev
> *mddev, struct md_rdev *rdev)
>       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;
>
> --
> 2.31.1
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-12  2:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-09 11:53 [PATCH] raid1: fix error: ISO C90 forbids mixed declarations Nigel Croxon
2023-09-11 21:42 ` Song Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).