]> git.baikalelectronics.ru Git - kernel.git/commit
leds: led-class: Add missing put_device() to led_put()
authorHans de Goede <hdegoede@redhat.com>
Fri, 20 Jan 2023 11:45:14 +0000 (12:45 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 10 Mar 2023 08:32:57 +0000 (09:32 +0100)
commit0257edf85e6581f412000843e24c0807bf8dd2ca
tree072d3a31ac854e0ac67dafa5618ef76f147b6b2a
parentcd5dbb0971f012dbb18a9ae4d56c0f5ca6f1ecec
leds: led-class: Add missing put_device() to led_put()

[ Upstream commit 4b090b4cb906f8f420257a8432c19d8f07fc3f27 ]

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: 6ddb535b2a8c ("leds: Add of_led_get() and led_put()")
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Lee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20230120114524.408368-2-hdegoede@redhat.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/leds/led-class.c