Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 96a2e242a5dc ("leds: flash: Add driver to support flash LED module in QCOM PMICs")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://lore.kernel.org/r/ZoWJS_epjIMCYITg@stanley.mountain
Signed-off-by: Lee Jones <lee@kernel.org>

authored by

Dan Carpenter and committed by
Lee Jones
87e552ad 4137d94f

+7 -3
+7 -3
drivers/leds/flash/leds-qcom-flash.c
··· 505 505 struct qcom_flash_data *flash_data = led->flash_data; 506 506 struct v4l2_flash_config v4l2_cfg = { 0 }; 507 507 struct led_flash_setting *intensity = &v4l2_cfg.intensity; 508 + struct v4l2_flash *v4l2_flash; 508 509 509 510 if (!(led->flash.led_cdev.flags & LED_DEV_CAP_FLASH)) 510 511 return 0; ··· 524 523 LED_FAULT_OVER_TEMPERATURE | 525 524 LED_FAULT_TIMEOUT; 526 525 527 - flash_data->v4l2_flash[flash_data->leds_count] = 528 - v4l2_flash_init(dev, fwnode, &led->flash, &qcom_v4l2_flash_ops, &v4l2_cfg); 529 - return PTR_ERR_OR_ZERO(flash_data->v4l2_flash); 526 + v4l2_flash = v4l2_flash_init(dev, fwnode, &led->flash, &qcom_v4l2_flash_ops, &v4l2_cfg); 527 + if (IS_ERR(v4l2_flash)) 528 + return PTR_ERR(v4l2_flash); 529 + 530 + flash_data->v4l2_flash[flash_data->leds_count] = v4l2_flash; 531 + return 0; 530 532 } 531 533 # else 532 534 static int