* [PATCH] leds: flash: leds-qcom-flash: Test the correct variable in init
@ 2024-07-04 15:19 Dan Carpenter
2024-07-04 17:04 ` (subset) " Lee Jones
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2024-07-04 15:19 UTC (permalink / raw)
To: Pavel Machek, Fenglin Wu
Cc: Lee Jones, Uwe Kleine-König, linux-leds, linux-kernel,
kernel-janitors
This code was passing the incorrect pointer to PTR_ERR_OR_ZERO() so it
always returned success. It should have been checking the array element
instead of the array itself.
Fixes: 96a2e242a5dc ("leds: flash: Add driver to support flash LED module in QCOM PMICs")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/leds/flash/leds-qcom-flash.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/leds/flash/leds-qcom-flash.c b/drivers/leds/flash/leds-qcom-flash.c
index 7c99a3039171..bf70bf6fb0d5 100644
--- a/drivers/leds/flash/leds-qcom-flash.c
+++ b/drivers/leds/flash/leds-qcom-flash.c
@@ -505,6 +505,7 @@ qcom_flash_v4l2_init(struct device *dev, struct qcom_flash_led *led, struct fwno
struct qcom_flash_data *flash_data = led->flash_data;
struct v4l2_flash_config v4l2_cfg = { 0 };
struct led_flash_setting *intensity = &v4l2_cfg.intensity;
+ struct v4l2_flash *v4l2_flash;
if (!(led->flash.led_cdev.flags & LED_DEV_CAP_FLASH))
return 0;
@@ -523,9 +524,12 @@ qcom_flash_v4l2_init(struct device *dev, struct qcom_flash_led *led, struct fwno
LED_FAULT_OVER_TEMPERATURE |
LED_FAULT_TIMEOUT;
- flash_data->v4l2_flash[flash_data->leds_count] =
- v4l2_flash_init(dev, fwnode, &led->flash, &qcom_v4l2_flash_ops, &v4l2_cfg);
- return PTR_ERR_OR_ZERO(flash_data->v4l2_flash);
+ v4l2_flash = v4l2_flash_init(dev, fwnode, &led->flash, &qcom_v4l2_flash_ops, &v4l2_cfg);
+ if (IS_ERR(v4l2_flash))
+ return PTR_ERR(v4l2_flash);
+
+ flash_data->v4l2_flash[flash_data->leds_count] = v4l2_flash;
+ return 0;
}
# else
static int
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: (subset) [PATCH] leds: flash: leds-qcom-flash: Test the correct variable in init
2024-07-04 15:19 [PATCH] leds: flash: leds-qcom-flash: Test the correct variable in init Dan Carpenter
@ 2024-07-04 17:04 ` Lee Jones
0 siblings, 0 replies; 2+ messages in thread
From: Lee Jones @ 2024-07-04 17:04 UTC (permalink / raw)
To: Pavel Machek, Fenglin Wu, Dan Carpenter
Cc: Lee Jones, Uwe Kleine-König, linux-leds, linux-kernel,
kernel-janitors
On Thu, 04 Jul 2024 10:19:32 -0500, Dan Carpenter wrote:
> This code was passing the incorrect pointer to PTR_ERR_OR_ZERO() so it
> always returned success. It should have been checking the array element
> instead of the array itself.
>
>
Applied, thanks!
[1/1] leds: flash: leds-qcom-flash: Test the correct variable in init
commit: b9bd590268485652b928110b5543057543b5d02b
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-07-04 17:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-04 15:19 [PATCH] leds: flash: leds-qcom-flash: Test the correct variable in init Dan Carpenter
2024-07-04 17:04 ` (subset) " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).