KSPP / linux

Linux kernel source tree (Kernel Self Protection Project)
https://kernsec.org/wiki/index.php/Kernel_Self_Protection_Project
Other
83 stars 5 forks source link

"error: invalid application of ‘sizeof’ to incomplete type" in sound/pci/hda/patch_realtek.c #50

Closed GustavoARSilva closed 9 months ago

GustavoARSilva commented 4 years ago

When replacing the one-element array alc_mute_keycode_map[1] with a flexible-array member in struct alc_spec:

diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c
index 377565696e98..ff8202fcd412 100644
--- a/sound/pci/hda/patch_realtek.c
+++ b/sound/pci/hda/patch_realtek.c
@@ -124,7 +124,7 @@ struct alc_spec {
        unsigned int pll_coef_idx, pll_coef_bit;
        unsigned int coef0;
        struct input_dev *kb_dev;
-       u8 alc_mute_keycode_map[1];
+       u8 alc_mute_keycode_map[];
 };

 /*

the following errors show up:

  CC      sound/pci/hda/patch_realtek.o
In file included from ./include/linux/delay.h:22,
                 from sound/pci/hda/patch_realtek.c:14:
sound/pci/hda/patch_realtek.c: In function ‘alc_register_micmute_input_device’:
./include/linux/kernel.h:47:32: error: invalid application of ‘sizeof’ to incomplete type ‘u8[]’ {aka ‘unsigned char[]’}
   47 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
      |                                ^
sound/pci/hda/patch_realtek.c:4364:29: note: in expansion of macro ‘ARRAY_SIZE’
 4364 |  spec->kb_dev->keycodemax = ARRAY_SIZE(spec->alc_mute_keycode_map);
      |                             ^~~~~~~~~~
./include/linux/kernel.h:47:32: error: invalid application of ‘sizeof’ to incomplete type ‘u8[]’ {aka ‘unsigned char[]’}
   47 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
      |                                ^
sound/pci/hda/patch_realtek.c:4366:18: note: in expansion of macro ‘ARRAY_SIZE’
 4366 |  for (i = 0; i < ARRAY_SIZE(spec->alc_mute_keycode_map); i++)
      |                  ^~~~~~~~~~
scripts/Makefile.build:272: recipe for target 'sound/pci/hda/patch_realtek.o' failed
make[3]: *** [sound/pci/hda/patch_realtek.o] Error 1
scripts/Makefile.build:494: recipe for target 'sound/pci/hda' failed
make[2]: *** [sound/pci/hda] Error 2
scripts/Makefile.build:494: recipe for target 'sound/pci' failed
make[1]: *** [sound/pci] Error 2
Makefile:1728: recipe for target 'sound' failed
make: *** [sound] Error 2

See flexible-array conversions issue.

kees commented 9 months ago

This is a non-issue. It's literally a single element array.