Patch "leds: led-class: Add missing put_device() to led_put()" has been added to the 6.1-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    leds: led-class: Add missing put_device() to led_put()

to the 6.1-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     leds-led-class-add-missing-put_device-to-led_put.patch
and it can be found in the queue-6.1 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9d1ba4e1752385f41e9beec3f1d688d924d6177c
Author: Hans de Goede <hdegoede@xxxxxxxxxx>
Date:   Fri Jan 20 12:45:14 2023 +0100

    leds: led-class: Add missing put_device() to led_put()
    
    [ Upstream commit 445110941eb94709216363f9d807d2508e64abd7 ]
    
    led_put() is used to "undo" a successful of_led_get() call,
    of_led_get() uses class_find_device_by_of_node() which returns
    a reference to the device which must be free-ed with put_device()
    when the caller is done with it.
    
    Add a put_device() call to led_put() to free the reference returned
    by class_find_device_by_of_node().
    
    And also add a put_device() in the error-exit case of try_module_get()
    failing.
    
    Fixes: 699a8c7c4bd3 ("leds: Add of_led_get() and led_put()")
    Reviewed-by: Andy Shevchenko <andy.shevchenko@xxxxxxxxx>
    Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
    Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230120114524.408368-2-hdegoede@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index 6a8ea94834fa3..7391d2cf1370a 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -241,8 +241,10 @@ struct led_classdev *of_led_get(struct device_node *np, int index)
 
 	led_cdev = dev_get_drvdata(led_dev);
 
-	if (!try_module_get(led_cdev->dev->parent->driver->owner))
+	if (!try_module_get(led_cdev->dev->parent->driver->owner)) {
+		put_device(led_cdev->dev);
 		return ERR_PTR(-ENODEV);
+	}
 
 	return led_cdev;
 }
@@ -255,6 +257,7 @@ EXPORT_SYMBOL_GPL(of_led_get);
 void led_put(struct led_classdev *led_cdev)
 {
 	module_put(led_cdev->dev->parent->driver->owner);
+	put_device(led_cdev->dev);
 }
 EXPORT_SYMBOL_GPL(led_put);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux