WSL2-Linux-Kernel/drivers
Luca Ceresoli 0781e42311 Revert "leds: led-core: Fix refcount leak in of_led_get()"
[ Upstream commit 940b27161afc6ec53fc66245a4fb3518394cdc92 ]

This reverts commit da1afe8e60.

Commit 699a8c7c4b ("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 da1afe8e60 ("leds: led-core: Fix refcount leak in of_led_get()")
 - commit 445110941e ("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 da1afe8e60 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 (445110941e) is adding the put_device() in led_put() so it
covers the entire lifetime, and it works even in the non-DT case.

Fixes: da1afe8e60 ("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-08-19 05:45:02 +02:00
..
accessibility speakup: Fix sizeof() vs ARRAY_SIZE() bug 2024-06-16 13:39:11 +02:00
acpi ACPI: EC: Avoid returning AE_OK on errors in address space handler 2024-07-27 10:46:07 +02:00
amba
android binder: fix max_thread type inconsistency 2024-05-25 16:20:18 +02:00
ata ata: libata-core: Fix double free on error 2024-07-05 09:14:49 +02:00
atm atm: idt77252: fix a memleak in open_card_ubr0 2024-02-23 08:54:57 +01:00
auxdisplay
base regmap-i2c: Subtract reg size from max_write 2024-07-18 13:07:35 +02:00
bcma
block null_blk: fix validation of block size 2024-07-27 10:46:09 +02:00
bluetooth Bluetooth: qca: Fix BT enable failure again for QCA6390 after warm reboot 2024-07-18 13:07:33 +02:00
bus bus: tegra-aconnect: Update dependency to ARCH_TEGRA 2024-03-26 18:21:19 -04:00
cdrom
char hpet: Support 32-bit userspace 2024-07-18 13:07:41 +02:00
clk clk: qcom: gcc-sm6350: Fix gpll6* & gpll7 parents 2024-07-18 13:07:34 +02:00
clocksource clocksource/drivers/arm_global_timer: Fix maximum prescaler value 2024-04-10 16:18:46 +02:00
comedi comedi: vmk80xx: fix incomplete endpoint checking 2024-04-27 17:05:26 +02:00
connector
counter
cpufreq cppc_cpufreq: Fix possible null pointer dereference 2024-06-16 13:39:21 +02:00
cpuidle cpuidle: Avoid potential overflow in integer multiplication 2024-04-13 13:01:43 +02:00
crypto crypto: hisilicon/sec - Fix memory leak for sec resource release 2024-07-05 09:14:24 +02:00
cxl
dax
dca
devfreq PM / devfreq: Synchronize devfreq_monitor_[start/stop] 2024-02-23 08:54:38 +01:00
dio
dma dmaengine: ioatdma: Fix missing kmem_cache_destroy() 2024-07-05 09:14:33 +02:00
dma-buf dma-buf/sw-sync: don't enable IRQ from sync_print_obj() 2024-06-16 13:39:49 +02:00
edac EDAC, i10nm: make skx_common.o a separate module 2024-08-19 05:44:49 +02:00
eisa
extcon extcon: max8997: select IRQ_DOMAIN instead of depending on it 2024-06-16 13:39:39 +02:00
firewire firewire: nosy: ensure user_length is taken into account when fetching packet contents 2024-05-17 11:51:01 +02:00
firmware firmware: turris-mox-rwtm: Initialize completion before mailbox 2024-08-19 05:44:55 +02:00
fpga fpga: region: add owner module and take its refcount 2024-06-16 13:39:38 +02:00
fsi
gnss
gpio gpiolib: of: add polarity quirk for TSC2005 2024-07-18 13:07:32 +02:00
gpu drm/qxl: Add check for drm_cvt_mode 2024-08-19 05:45:02 +02:00
greybus greybus: Fix use-after-free bug in gb_interface_release due to race condition. 2024-07-05 09:14:23 +02:00
hid HID: Add quirk for Logitech Casa touchpad 2024-07-05 09:14:26 +02:00
hsi
hv
hwmon hwmon: (max6697) Fix swapped temp{1,8} critical alarms 2024-08-19 05:44:51 +02:00
hwspinlock
hwtracing intel_th: pci: Add Lunar Lake support 2024-07-05 09:14:22 +02:00
i2c i2c: rcar: fix error code in probe() 2024-07-18 13:07:45 +02:00
i3c i3c: master: svc: fix invalidate IBI type and miss call client IBI handler 2024-06-16 13:40:00 +02:00
idle
iio iio: chemical: bme680: Fix sensor data read operation 2024-07-05 09:14:46 +02:00
infiniband IB/core: Implement a limit on UMAD receive List 2024-07-18 13:07:26 +02:00
input Input: i8042 - add Ayaneo Kun to i8042 quirk table 2024-07-27 10:46:11 +02:00
interconnect Revert "interconnect: Teach lockdep about icc_bw_lock order" 2024-03-06 14:38:50 +00:00
iommu iommu/arm-smmu-v3: Free MSIs in case of ENOMEM 2024-07-05 09:14:27 +02:00
ipack
irqchip irqchip/loongson-pch-msi: Fix off-by-one on allocation error path 2024-06-16 13:39:20 +02:00
isdn
leds Revert "leds: led-core: Fix refcount leak in of_led_get()" 2024-08-19 05:45:02 +02:00
macintosh macintosh/via-macii: Fix "BUG: sleeping function called from invalid context" 2024-06-16 13:39:23 +02:00
mailbox mailbox: arm_mhuv2: Fix a bug for mhuv2_sender_interrupt 2024-02-23 08:54:50 +01:00
mcb mcb: fix error handling for different scenarios when parsing 2023-11-28 16:56:31 +00:00
md bcache: fix variable length array abuse in btree_iter 2024-07-05 09:14:36 +02:00
media media: renesas: vsp1: Store RPF partition configuration per RPF instance 2024-08-19 05:45:01 +02:00
memory memory: fsl_ifc: Make FSL_IFC config visible and selectable 2024-08-19 05:44:52 +02:00
memstick
message
mfd mfd: altera-sysmgr: Call of_node_put() only when of_parse_phandle() takes a ref 2024-03-26 18:21:29 -04:00
misc mei: demote client disconnect warning on suspend to debug 2024-07-27 10:46:10 +02:00
mmc mmc: sdhci: Do not lock spinlock around mmc_gpio_get_ro() 2024-07-05 09:14:45 +02:00
most
mtd memory: fsl_ifc: Make FSL_IFC config visible and selectable 2024-08-19 05:44:52 +02:00
mux
net bna: adjust 'name' buf size of bna_tcb and bna_ccb structures 2024-08-19 05:44:59 +02:00
nfc nfc/nci: Add the inconsistency check between the input data length and count 2024-07-18 13:07:36 +02:00
ntb NTB: fix possible name leak in ntb_register_device() 2024-03-26 18:21:28 -04:00
nubus
nvdimm
nvme nvme: avoid double free special payload 2024-07-27 10:46:10 +02:00
nvmem nvmem: core: only change name to fram for current attribute 2024-07-18 13:07:42 +02:00
of cma: factor out minimum alignment requirement 2024-07-05 09:14:13 +02:00
opp OPP: debugfs: Fix warning around icc_get_name() 2024-03-26 18:21:23 -04:00
parisc
parport parport: parport_serial: Add Brainboxes device IDs and geometry 2024-01-25 14:52:31 -08:00
pci PCI/PM: Avoid D3cold for HP Pavilion 17 PC/1972 PCIe Ports 2024-07-05 09:14:28 +02:00
pcmcia
perf
phy phy: tegra: xusb: Add API to retrieve the port number of phy 2024-04-10 16:18:40 +02:00
pinctrl pinctrl: rockchip: fix pinmux reset in rockchip_pmx_set 2024-07-05 09:14:40 +02:00
platform platform/chrome: cros_ec_debugfs: fix wrong EC message version 2024-08-19 05:44:49 +02:00
pnp PNP: ACPI: fix fortify warning 2024-02-23 08:54:38 +01:00
power power: supply: cros_usbpd: provide ID table for avoiding fallback match 2024-07-05 09:14:27 +02:00
powercap
pps
ps3
ptp ptp: fix integer overflow in max_vclocks_store 2024-07-05 09:14:31 +02:00
pwm pwm: stm32: Always do lazy disabling 2024-08-19 05:44:51 +02:00
rapidio
ras
regulator regulator: bd71815: fix ramp values 2024-07-05 09:14:33 +02:00
remoteproc remoteproc: mediatek: Make sure IPI buffer fits in L2TCM 2024-05-25 16:20:18 +02:00
reset reset: hisilicon: hi6220: fix Wvoid-pointer-to-enum-cast warning 2024-01-25 14:52:30 -08:00
rpmsg rpmsg: virtio: Free driver_override when rpmsg_remove() 2024-02-23 08:54:24 +01:00
rtc rtc: mt6397: select IRQ_DOMAIN instead of depending on it 2024-03-26 18:21:34 -04:00
s390 s390/sclp: Fix sclp_init() cleanup on failure 2024-07-27 10:46:11 +02:00
sbus
scsi scsi: libsas: Fix exp-attached device scan after probe failure scanned in again after probe failed 2024-07-27 10:46:13 +02:00
sh
siox
slimbus slimbus: qcom-ngd-ctrl: Add timeout for wait operation 2024-05-17 11:51:04 +02:00
soc soc: qcom: pdr: fix parsing of domains lists 2024-08-19 05:44:52 +02:00
soundwire soundwire: cadence: fix invalid PDI offset 2024-06-16 13:39:34 +02:00
spi spi: mux: set ctlr->bits_per_word_mask 2024-07-27 10:46:14 +02:00
spmi spmi: hisi-spmi-controller: Do not override device identifier 2024-07-05 09:14:20 +02:00
ssb
staging greybus: arche-ctrl: move device table to its right location 2024-06-16 13:39:35 +02:00
target scsi: target: Fix SELinux error when systemd-modules loads the target module 2024-05-17 11:50:54 +02:00
tc
tee tee: optee: Fix kernel panic caused by incorrect error handling 2024-04-10 16:18:46 +02:00
thermal thermal/drivers/qcom/lmh: Check for SCM availability at probe 2024-06-16 13:39:55 +02:00
thunderbolt thunderbolt: Fix wake configurations after device unplug 2024-04-27 17:05:26 +02:00
tty serial: 8250_omap: Fix Errata i2310 with RX FIFO level check 2024-07-05 09:14:52 +02:00
uio uio: Fix use-after-free in uio_open 2024-01-25 14:52:31 -08:00
usb USB: core: Fix duplicate endpoint bug by clearing reserved bits in the descriptor 2024-07-18 13:07:41 +02:00
vdpa vduse: Temporarily fail if control queue feature requested 2024-07-05 09:14:42 +02:00
vfio vfio/fsl-mc: Block calling interrupt handler without trigger 2024-04-10 16:19:30 +02:00
vhost vhost: Add smp_rmb() in vhost_vq_avail_empty() 2024-04-17 11:15:16 +02:00
video fbdev: savage: Handle err return when savagefb_check_var failed 2024-06-16 13:39:57 +02:00
virt drivers/virt/acrn: fix PFNMAP PTE checks in acrn_vm_ram_map() 2024-06-16 13:39:32 +02:00
virtio virtio: delete vq in vp_find_vqs_msix() when request_irq() fails 2024-06-16 13:39:47 +02:00
visorbus
vlynq
vme
w1
watchdog watchdog: rti_wdt: Set min_hw_heartbeat_ms to accommodate a safety margin 2024-06-16 13:39:59 +02:00
xen xen/events: close evtchn after mapping cleanup 2024-04-10 16:18:46 +02:00
zorro
Kconfig
Makefile