Linux LED subsystem development
 help / color / mirror / Atom feed
* [PATCH v2 1/2] leds: flash: Prevent using uninitialized variable in flash_fault_show()
@ 2026-09-04  7:08 Dmitry Antipov
  2026-09-04  7:08 ` [PATCH v2 2/2] leds: flash: Simplify flash_fault_show() Dmitry Antipov
  2026-09-04  7:21 ` [PATCH v2 1/2] leds: flash: Prevent using uninitialized variable in flash_fault_show() sashiko-bot
  0 siblings, 2 replies; 4+ messages in thread
From: Dmitry Antipov @ 2026-09-04  7:08 UTC (permalink / raw)
  To: Lee Jones, Pavel Machek; +Cc: linux-leds, Dmitry Antipov, sashiko-bot

In flash_fault_show(), address of uninitialized 'fault' variable is
passed to device-specific .fault_get callbacks. This is not a problem
if such a callback directly assigns the value like rt4505_fault_get(),
but results in an undefined behavior if callback just performs bitwise
ORs like as3645a_get_fault(). So just initialize 'fault' with zero.

Reported-by: sashiko-bot@kernel.org
Closes: https://sashiko.dev/#/patchset/20260904054437.461706-1-dmantipov@yandex.ru?part=1
Fixes: 7aea8389a77ab ("leds: Add LED Flash class extension to the LED subsystem")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v2: initial version to join the series
---
 drivers/leds/led-class-flash.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c
index 165035a8826c..3bb90823de1a 100644
--- a/drivers/leds/led-class-flash.c
+++ b/drivers/leds/led-class-flash.c
@@ -187,7 +187,7 @@ static ssize_t flash_fault_show(struct device *dev,
 {
 	struct led_classdev *led_cdev = dev_get_drvdata(dev);
 	struct led_classdev_flash *fled_cdev = lcdev_to_flcdev(led_cdev);
-	u32 fault, mask = 0x1;
+	u32 fault = 0, mask = 0x1;
 	char *pbuf = buf;
 	int i, ret, buf_len;
 
-- 
2.55.0


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

end of thread, other threads:[~2026-09-04  7:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-04  7:08 [PATCH v2 1/2] leds: flash: Prevent using uninitialized variable in flash_fault_show() Dmitry Antipov
2026-09-04  7:08 ` [PATCH v2 2/2] leds: flash: Simplify flash_fault_show() Dmitry Antipov
2026-09-04  7:11   ` sashiko-bot
2026-09-04  7:21 ` [PATCH v2 1/2] leds: flash: Prevent using uninitialized variable in flash_fault_show() sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox