Commit 4016ba85 authored by Oleh Kravchenko's avatar Oleh Kravchenko Committed by Jacek Anaszewski

led: triggers: Fix dereferencing of null pointer

Error was detected by PVS-Studio:
V522 Dereferencing of the null pointer 'led_cdev->trigger' might take place.

Fixes: 2282e125 ("leds: triggers: let struct led_trigger::activate() return an error code")
Signed-off-by: default avatarOleh Kravchenko <oleg@kaa.org.ua>
Reviewed-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarJacek Anaszewski <jacek.anaszewski@gmail.com>
parent ba7eb84f
...@@ -167,11 +167,11 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig) ...@@ -167,11 +167,11 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
trig->deactivate(led_cdev); trig->deactivate(led_cdev);
err_activate: err_activate:
led_cdev->trigger = NULL;
led_cdev->trigger_data = NULL;
write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags); write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
list_del(&led_cdev->trig_list); list_del(&led_cdev->trig_list);
write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock, flags); write_unlock_irqrestore(&led_cdev->trigger->leddev_list_lock, flags);
led_cdev->trigger = NULL;
led_cdev->trigger_data = NULL;
led_set_brightness(led_cdev, LED_OFF); led_set_brightness(led_cdev, LED_OFF);
kfree(event); kfree(event);
......
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