Commit 87e552ad authored by Dan Carpenter's avatar Dan Carpenter Committed by Lee Jones

leds: flash: leds-qcom-flash: Test the correct variable in init

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: 96a2e242 ("leds: flash: Add driver to support flash LED module in QCOM PMICs")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/ZoWJS_epjIMCYITg@stanley.mountainSigned-off-by: default avatarLee Jones <lee@kernel.org>
parent 4137d94f
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment