Linux-LEDs Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] led: triggers: Fix dereferencing of null pointer
@ 2019-09-03 21:18 Oleh Kravchenko
  2019-09-05 20:37 ` Jacek Anaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Oleh Kravchenko @ 2019-09-03 21:18 UTC (permalink / raw)
  To: linux-leds; +Cc: Oleh Kravchenko

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

Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua>
---
 drivers/leds/led-triggers.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
index eff1bda8b520..23963e5cb5d6 100644
--- a/drivers/leds/led-triggers.c
+++ b/drivers/leds/led-triggers.c
@@ -167,11 +167,11 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
 		trig->deactivate(led_cdev);
 err_activate:
 
-	led_cdev->trigger = NULL;
-	led_cdev->trigger_data = NULL;
 	write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
 	list_del(&led_cdev->trig_list);
 	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);
 	kfree(event);
 
-- 
2.21.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] led: triggers: Fix dereferencing of null pointer
  2019-09-03 21:18 [PATCH] led: triggers: Fix dereferencing of null pointer Oleh Kravchenko
@ 2019-09-05 20:37 ` Jacek Anaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Jacek Anaszewski @ 2019-09-05 20:37 UTC (permalink / raw)
  To: Oleh Kravchenko, linux-leds

Hi Oleh,

Thank you for the patch

On 9/3/19 11:18 PM, Oleh Kravchenko wrote:
> Error was detected by PVS-Studio:
> V522 Dereferencing of the null pointer 'led_cdev->trigger' might take place.
> 
> Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua>
> ---
>  drivers/leds/led-triggers.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/leds/led-triggers.c b/drivers/leds/led-triggers.c
> index eff1bda8b520..23963e5cb5d6 100644
> --- a/drivers/leds/led-triggers.c
> +++ b/drivers/leds/led-triggers.c
> @@ -167,11 +167,11 @@ int led_trigger_set(struct led_classdev *led_cdev, struct led_trigger *trig)
>  		trig->deactivate(led_cdev);
>  err_activate:
>  
> -	led_cdev->trigger = NULL;
> -	led_cdev->trigger_data = NULL;
>  	write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
>  	list_del(&led_cdev->trig_list);
>  	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);
>  	kfree(event);
>  
> 

Added tag:

Fixes: 2282e125a406 ("leds: triggers: let struct led_trigger::activate()
return an error code")

and applied.

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03 21:18 [PATCH] led: triggers: Fix dereferencing of null pointer Oleh Kravchenko
2019-09-05 20:37 ` Jacek Anaszewski

Linux-LEDs Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-leds/0 linux-leds/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-leds linux-leds/ https://lore.kernel.org/linux-leds \
		linux-leds@vger.kernel.org linux-leds@archiver.kernel.org
	public-inbox-index linux-leds


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-leds


AGPL code for this site: git clone https://public-inbox.org/ public-inbox