linux-stable/drivers/pcmcia
Armin Wolf 2d45e2be0b pcmcia: rsrc_nonstatic: Fix memory leak in nonstatic_release_resource_db()
[ Upstream commit c85fd9422f ]

When nonstatic_release_resource_db() frees all resources associated
with an PCMCIA socket, it forgets to free socket_data too, causing
a memory leak observable with kmemleak:

unreferenced object 0xc28d1000 (size 64):
  comm "systemd-udevd", pid 297, jiffies 4294898478 (age 194.484s)
  hex dump (first 32 bytes):
    00 00 00 00 00 00 00 00 f0 85 0e c3 00 00 00 00  ................
    00 00 00 00 0c 10 8d c2 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<ffda4245>] __kmem_cache_alloc_node+0x2d7/0x4a0
    [<7e51f0c8>] kmalloc_trace+0x31/0xa4
    [<d52b4ca0>] nonstatic_init+0x24/0x1a4 [pcmcia_rsrc]
    [<a2f13e08>] pcmcia_register_socket+0x200/0x35c [pcmcia_core]
    [<a728be1b>] yenta_probe+0x4d8/0xa70 [yenta_socket]
    [<c48fac39>] pci_device_probe+0x99/0x194
    [<84b7c690>] really_probe+0x181/0x45c
    [<8060fe6e>] __driver_probe_device+0x75/0x1f4
    [<b9b76f43>] driver_probe_device+0x28/0xac
    [<648b766f>] __driver_attach+0xeb/0x1e4
    [<6e9659eb>] bus_for_each_dev+0x61/0xb4
    [<25a669f3>] driver_attach+0x1e/0x28
    [<d8671d6b>] bus_add_driver+0x102/0x20c
    [<df0d323c>] driver_register+0x5b/0x120
    [<942cd8a4>] __pci_register_driver+0x44/0x4c
    [<e536027e>] __UNIQUE_ID___addressable_cleanup_module188+0x1c/0xfffff000 [iTCO_vendor_support]

Fix this by freeing socket_data too.

Tested on a Acer Travelmate 4002WLMi by manually binding/unbinding
the yenta_cardbus driver (yenta_socket).

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Message-ID: <20230512184529.5094-1-W_Armin@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-08-30 16:31:43 +02:00
..
at91_cf.c pcmcia: at91_cf: Use PTR_ERR_OR_ZERO() 2017-11-29 21:58:58 +01:00
bcm63xx_pcmcia.c drivers/pcmcia: Convert timers to use timer_setup() 2017-11-04 12:03:13 +01:00
bcm63xx_pcmcia.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cardbus.c PCI: Add for_each_pci_bridge() helper 2017-11-06 18:48:58 -06:00
cirrus.h
cistpl.c treewide: kmalloc() -> kmalloc_array() 2018-06-12 16:19:22 -07:00
cs.c pcmcia: fix setting of kthread task states 2022-01-27 09:04:21 +01:00
cs_internal.h PCMCIA / PM: Avoid noirq suspend aborts during suspend-to-idle 2018-02-22 22:51:12 +01:00
db1xxx_ss.c MIPS: Alchemy: Threaded carddetect irqs for devboards 2017-08-29 15:21:53 +02:00
ds.c
electra_cf.c pcmcia/electra_cf: Convert timers to use timer_setup() 2017-10-18 12:39:37 +01:00
i82092.c pcmcia: i82092: fix a null pointer dereference bug 2021-08-12 13:19:43 +02:00
i82092aa.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
i82365.c drivers/pcmcia: Convert timers to use timer_setup() 2017-11-04 12:03:13 +01:00
i82365.h
Kconfig pcmcia: db1xxx_ss: restrict to MIPS_DB1XXX boards 2022-06-14 16:59:31 +02:00
Makefile Merge branch 'for-linus-sa1100' of git://git.armlinux.org.uk/~rmk/linux-arm 2018-04-09 09:26:36 -07:00
o2micro.h
omap_cf.c drivers/pcmcia: omap1: Fix error in automated timer conversion 2017-11-06 12:49:15 -08:00
pcmcia_cis.c
pcmcia_resource.c pcmcia: remove long deprecated pcmcia_request_exclusive_irq() function 2018-08-18 12:30:42 -07:00
pd6729.c treewide: kzalloc() -> kcalloc() 2018-06-12 16:19:22 -07:00
pd6729.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pxa2xx_balloon3.c
pxa2xx_base.c
pxa2xx_base.h
pxa2xx_cm_x2xx.c
pxa2xx_cm_x255.c
pxa2xx_cm_x270.c
pxa2xx_colibri.c
pxa2xx_e740.c
pxa2xx_hx4700.c
pxa2xx_mainstone.c
pxa2xx_palmld.c
pxa2xx_palmtc.c
pxa2xx_palmtx.c
pxa2xx_sharpsl.c
pxa2xx_stargate2.c
pxa2xx_trizeps4.c
pxa2xx_viper.c
pxa2xx_vpac270.c
ricoh.h pcmcia: Implement CLKRUN protocol disabling for Ricoh bridges 2018-11-13 11:08:17 -08:00
rsrc_iodyn.c
rsrc_mgr.c
rsrc_nonstatic.c pcmcia: rsrc_nonstatic: Fix memory leak in nonstatic_release_resource_db() 2023-08-30 16:31:43 +02:00
sa11xx_base.c
sa11xx_base.h
sa1100_generic.c ARM: sa1100/shannon: convert to generic CF sockets 2018-04-06 15:53:22 +01:00
sa1100_generic.h ARM: sa1100/shannon: convert to generic CF sockets 2018-04-06 15:53:22 +01:00
sa1100_h3600.c ARM: sa1100/h3xxx: switch h3xxx PCMCIA to use gpiod APIs 2018-03-24 14:17:09 +00:00
sa1100_simpad.c ARM: sa1100/simpad: switch simpad CF to use gpiod APIs 2018-04-06 15:53:22 +01:00
sa1111_badge4.c drivers/pcmcia/sa1111_badge4.c: avoid unused function warning 2017-11-17 16:10:04 -08:00
sa1111_generic.c pcmcia: sa1111: remove special sa1111 mmio accessors 2017-10-03 13:24:11 +01:00
sa1111_generic.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sa1111_jornada720.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
sa1111_lubbock.c
sa1111_neponset.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
soc_common.c pcmcia: soc_common: Handle return value of clk_prepare_enable 2018-01-24 19:24:39 +01:00
soc_common.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
socket_sysfs.c
tcic.c drivers/pcmcia: Convert timers to use timer_setup() 2017-11-04 12:03:13 +01:00
tcic.h
ti113x.h
topic.h
vg468.h
vrc4171_card.c
vrc4173_cardu.c
vrc4173_cardu.h
xxs1500_ss.c
yenta_socket.c pcmcia: Implement CLKRUN protocol disabling for Ricoh bridges 2018-11-13 11:08:17 -08:00
yenta_socket.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00