[PATCH 20/21] leds: flash: Terminate sysfs_groups array with NULL

From: Lee Jones

Date: Wed Oct 21 2026 - 08:45:14 EST


led_flash_init_sysfs_groups() populates fled_cdev->sysfs_groups and
assigns it to led_cdev->groups without writing a trailing NULL entry.
If fled_cdev is not zero-initialised by the caller or is re-registered
with fewer operations, device_add_groups() will read past the populated
entries.

Explicitly NULL-terminate flash_groups at num_sysfs_groups.

Fixes: 7aea8389a77a ("leds: Add LED Flash class extension to the LED subsystem")
Closes: https://sashiko.dev/#/bug/linux-ad7bad43-ab12-40c5-addd-7d1f23d83391
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/leds/led-class-flash.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c
index 16b3b6b9365b..90ae93f16193 100644
--- a/drivers/leds/led-class-flash.c
+++ b/drivers/leds/led-class-flash.c
@@ -273,6 +273,8 @@ static void led_flash_init_sysfs_groups(struct led_classdev_flash *fled_cdev)
if (ops->fault_get)
flash_groups[num_sysfs_groups++] = &led_flash_fault_group;

+ flash_groups[num_sysfs_groups] = NULL;
+
led_cdev->groups = flash_groups;
}

--
2.56.0.218.g1ec904b173-goog