[PATCH] ARM: ixp4xx: Replace 0-length arrays with flexible arrays

Linus Walleij linus.walleij at linaro.org
Sat Jan 7 15:58:37 PST 2023


On Thu, Jan 5, 2023 at 10:57 PM Kees Cook <keescook at chromium.org> wrote:

> Zero-length arrays are deprecated[1]. Replace npe_load_firmware's
> union of 0-length arrays with flexible arrays. Detected with GCC 13,
> using -fstrict-flex-arrays=3:
>
> drivers/soc/ixp4xx/ixp4xx-npe.c: In function 'npe_load_firmware':
> drivers/soc/ixp4xx/ixp4xx-npe.c:570:60: warning: array subscript i is outside array bounds of 'u32[0]' {aka 'unsigned int[]'} [-Warray-bounds=]
>   570 |                         image->data[i] = swab32(image->data[i]);
> include/uapi/linux/swab.h:115:54: note: in definition of macro '__swab32'
>   115 | #define __swab32(x) (__u32)__builtin_bswap32((__u32)(x))
>       |                                                      ^
> drivers/soc/ixp4xx/ixp4xx-npe.c:570:42: note: in expansion of macro 'swab32'
>   570 |                         image->data[i] = swab32(image->data[i]);
>       |                                          ^~~~~~
> drivers/soc/ixp4xx/ixp4xx-npe.c:522:29: note: while referencing 'data'
>   522 |                         u32 data[0];
>       |                             ^~~~
>
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays
>
> Cc: Krzysztof Halasa <khalasa at piap.pl>
> Cc: Linus Walleij <linus.walleij at linaro.org>
> Cc: Arnd Bergmann <arnd at arndb.de>
> Cc: "Gustavo A. R. Silva" <gustavoars at kernel.org>
> Cc: linux-arm-kernel at lists.infradead.org
> Signed-off-by: Kees Cook <keescook at chromium.org>

Looks good to me:
Reviewed-by: Linus Walleij <linus.walleij at linaro.org>

Do you need me to funnel this to the SoC tree or do you have
some quickpath for fixes like this?

Yours,
Linus Walleij



More information about the linux-arm-kernel mailing list