[PATCH 2/2] leds: flash: qcom-flash: release v4l2 flash devices on torch clamp failure
From: Cong Nguyen
Date: Tue Nov 24 2026 - 04:56:15 EST
qcom_flash_led_probe() registers the LEDs and their v4l2 flash
sub-devices in a loop, and then returns the result of the final
regmap_field_write() of the torch clamp field. Every other failure after
the first v4l2_flash_init() jumps to the release label, which calls
v4l2_flash_release().
If this last write fails, probe fails without releasing the v4l2 flash
sub-devices. They are not device managed, so they stay registered after the
LED class devices that they use are freed.
Jump to the release label on failure of that write as well.
This issue was found by auditing the driver with an LLM coding assistant.
Fixes: 5974e8f6c3e4 ("leds: flash: leds-qcom-flash: Update torch current clamp setting")
Signed-off-by: Cong Nguyen <congnt264@xxxxxxxxx>
---
drivers/leds/flash/leds-qcom-flash.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/leds/flash/leds-qcom-flash.c b/drivers/leds/flash/leds-qcom-flash.c
index 1003ba060b42..b335784fe68c 100644
--- a/drivers/leds/flash/leds-qcom-flash.c
+++ b/drivers/leds/flash/leds-qcom-flash.c
@@ -951,7 +951,11 @@ static int qcom_flash_led_probe(struct platform_device *pdev)
flash_data->leds_count++;
}
- return regmap_field_write(flash_data->r_fields[REG_TORCH_CLAMP], flash_data->torch_clamp);
+ rc = regmap_field_write(flash_data->r_fields[REG_TORCH_CLAMP], flash_data->torch_clamp);
+ if (rc < 0)
+ goto release;
+
+ return 0;
release:
while (flash_data->leds_count)
v4l2_flash_release(flash_data->v4l2_flash[--flash_data->leds_count]);
--
2.25.1