kernel_samsung_a53x/drivers/leds
Luca Ceresoli 43859aa1b9 Revert "leds: led-core: Fix refcount leak in of_led_get()"
[ Upstream commit 940b27161afc6ec53fc66245a4fb3518394cdc92 ]

This reverts commit da1afe8e6099980fe1e2fd7436dca284af9d3f29.

Commit 699a8c7c4bd3 ("leds: Add of_led_get() and led_put()"), introduced in
5.5, added of_led_get() and led_put() but missed a put_device() in
led_put(), thus creating a leak in case the consumer device is removed.

Arguably device removal was not very popular, so this went apparently
unnoticed until 2022. In January 2023 two different patches got merged to
fix the same bug:

 - commit da1afe8e6099 ("leds: led-core: Fix refcount leak in of_led_get()")
 - commit 445110941eb9 ("leds: led-class: Add missing put_device() to led_put()")

They fix the bug in two different ways, which creates no patch conflicts,
and both were merged in v6.2. The result is that now there is one more
put_device() than get_device()s, instead of one less.

Arguably device removal is not very popular yet, so this apparently hasn't
been noticed as well up to now. But it blew up here while I'm working with
device tree overlay insertion and removal. The symptom is an apparently
unrelated list of oopses on device removal, with reasons:

  kernfs: can not remove 'uevent', no directory
  kernfs: can not remove 'brightness', no directory
  kernfs: can not remove 'max_brightness', no directory
  ...

Here sysfs fails removing attribute files, which is because the device name
changed and so the sysfs path. This is because the device name string got
corrupted, which is because it got freed too early and its memory reused.

Different symptoms could appear in different use cases.

Fix by removing one of the two fixes.

The choice was to remove commit da1afe8e6099 because:

 * it is calling put_device() inside of_led_get() just after getting the
   device, thus it is basically not refcounting the LED device at all
   during its entire lifetime
 * it does not add a corresponding put_device() in led_get(), so it fixes
   only the OF case

The other fix (445110941eb9) is adding the put_device() in led_put() so it
covers the entire lifetime, and it works even in the non-DT case.

Fixes: da1afe8e6099 ("leds: led-core: Fix refcount leak in of_led_get()")
Co-developed-by: Hervé Codina <herve.codina@bootlin.com>
Signed-off-by: Hervé Codina <herve.codina@bootlin.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Link: https://lore.kernel.org/r/20240625-led-class-device-leak-v2-1-75fdccf47421@bootlin.com
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-11-23 23:20:09 +01:00
..
trigger leds: trigger: panic: Don't register panic notifier if creating the trigger failed 2024-11-18 12:13:19 +01:00
Kconfig leds: aw2013: Select missing dependency REGMAP_I2C 2024-11-18 12:12:48 +01:00
led-class-flash.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
led-class-multicolor.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
led-class.c Revert "leds: led-core: Fix refcount leak in of_led_get()" 2024-11-23 23:20:09 +01:00
led-core.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
led-triggers.c leds: trigger: Unregister sysfs attributes before calling deactivate() 2024-11-23 23:20:09 +01:00
leds-88pm860x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-aat1290.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-acer-a500.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-adp5520.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-an30259a.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-apu.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-ariel.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-as3645a.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-asic3.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-aw2013.c leds: aw2013: Unlock mutex before destroying it 2024-11-19 08:44:55 +01:00
leds-bcm6328.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-bcm6358.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-bd2802.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-blinkm.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-clevo-mail.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-cobalt-qube.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-cobalt-raq.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-cpcap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-cr0014114.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-da903x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-da9052.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-dac124s085.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-el15203000.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-fsg.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-gpio-register.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-gpio.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-hp6xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-ip30.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-ipaq-micro.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-is31fl32xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-is31fl319x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-ktd2692.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lm355x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lm3530.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lm3532.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lm3533.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lm3601x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lm3642.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lm3692x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lm3697.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lm36274.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-locomo.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp50xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp55xx-common.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp55xx-common.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp3944.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp3952.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp5521.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp5523.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp5562.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp8501.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp8788.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lp8860.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-lt3593.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-max8997.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-max77650.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-max77693.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-mc13783.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-menf21bmc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-mlxcpld.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-mlxreg.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-mt6323.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-net48xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-netxbig.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-nic78bx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-ns2.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-ot200.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-pca955x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-pca963x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-pca9532.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-pm8058.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-powernv.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-pwm.c leds: pwm: Don't disable the PWM when the LED should be off 2024-11-18 11:43:05 +01:00
leds-rb532.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-regulator.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-s2mf301.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-s2mpb02.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-s2mu106.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-s3c24xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-sc27xx-bltc.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-sgm3140.c leds: sgm3140: Add missing timer cleanup and flash gpio control 2024-11-19 08:44:56 +01:00
leds-sm5714-fled.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-spi-byte.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-ss4200.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-sunfire.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-syscon.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-tca6507.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-ti-lmu-common.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-tlc591xx.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-tps6105x.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-turris-omnia.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-wm831x-status.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-wm8350.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds-wrap.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
leds.h Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
Makefile Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
TODO Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00
uleds.c Import A536BXXU9EXDC 2024-06-15 16:02:09 -03:00