leds: qpnp-flash-common: Fix possible null pointer dereference

Currently, there is no null check before using led_cdev.
Add a NULL pointer check before dereferencing it.

Change-Id: I4121be7511c299abbbda4de4de90f9d0a9168e15
Signed-off-by: Kavya Nunna <knunna@codeaurora.org>
This commit is contained in:
Kavya Nunna
2020-04-23 11:24:37 +05:30
parent 82e0a0f51b
commit 5e2a583cde

View File

@@ -39,6 +39,9 @@ int qpnp_flash_led_prepare(struct led_trigger *trig, int options,
int rc = -ENODEV;
led_cdev = trigger_to_lcdev(trig);
if (!led_cdev)
return rc;
list_for_each_entry(flash_data, &flash_common_data, link) {
if (led_cdev->dev->parent == flash_data->dev)
rc = flash_data->func(trig, options, max_current);