Skip to content

Commit 21d7ec7

Browse files
keesdtor
authored andcommitted
Input: leds - annotate struct input_leds with __counted_by
Prepare for the coming implementation by GCC and Clang of the __counted_by attribute. Flexible array members annotated with __counted_by can have their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family functions). As found with Coccinelle[1], add __counted_by for struct input_leds. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent 8927e68 commit 21d7ec7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/input/input-leds.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct input_led {
4444
struct input_leds {
4545
struct input_handle handle;
4646
unsigned int num_leds;
47-
struct input_led leds[];
47+
struct input_led leds[] __counted_by(num_leds);
4848
};
4949

5050
static enum led_brightness input_leds_brightness_get(struct led_classdev *cdev)

0 commit comments

Comments
 (0)