Re: [PATCH] led: triggers: Fix NULL dereference in led_trigger_set() error handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Dan,
If you amend my patch, please keep my Signed-of-by.

> 5 вер. 2019 р. о 12:57 пп Dan Carpenter <dan.carpenter@xxxxxxxxxx> написав(ла):
> 
> The problem is we set "led_cdev->trigger = NULL;" and then dereference
> it when we call write_lock_irqsave():
> 
> 	write_lock_irqsave(&led_cdev->trigger->leddev_list_lock, flags);
>                            ^^^^^^^^^^^^^^^^^
> 
> Fixes: 2282e125a406 ("leds: triggers: let struct led_trigger::activate() return an error code")
> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> ---
> 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..13cea227277c 100644
> --- a/drivers/leds/led-triggers.c
> +++ b/drivers/leds/led-triggers.c
> @@ -167,12 +167,12 @@ 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);
> 
> 	return ret;
> -- 
> 2.20.1
> 




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux