linux/drivers/mmc/core
Zhu Ling 08b54e16d5 mmc: core: Fix OF node reference leak on card add failure
mmc_of_find_child_device() returns a device node with its reference count
incremented. mmc_add_card() stores the reference before calling
device_add(), while the card is marked present only after device_add()
succeeds.

If device_add() fails, the callers release the card through
mmc_remove_card(). However, mmc_remove_card() only drops the OF node
reference for a present card, leaking the reference on this error path.

Move of_node_put() outside the present-card conditional so the reference
is released for both registered cards and card-add failures.

Fixes: 25185f3f31 ("mmc: Add SDIO function devicetree subnode parsing")
Cc: stable@vger.kernel.org
Signed-off-by: Zhu Ling <zhuling0805@qq.com>
Reviewed-by: Shawn Lin <shawn.lin@linux.dev>
Signed-off-by: Ulf Hansson <ulfh@kernel.org>
2026-09-10 14:20:54 +02:00
..
block.c mmc: block: reject invalid perdev_minors before division 2026-07-10 14:39:18 +02:00
block.h
bus.c mmc: core: Fix OF node reference leak on card add failure 2026-09-10 14:20:54 +02:00
bus.h mmc: use octal file permissions instead of symbolic 2025-10-21 13:37:38 +02:00
card.h mmc: core: Optimize time for secure erase/trim for some Kingston eMMCs 2026-02-23 12:06:55 +01:00
core.c mmc: core: Replace the hard-coded shift value 9 with SECTOR_SHIFT 2026-03-31 12:41:31 +02:00
core.h mmc: core: Add infrastructure for undervoltage handling 2025-08-22 12:08:07 +02:00
crypto.c blk-crypto: rename blk_keyslot_manager to blk_crypto_profile 2021-10-21 10:49:32 -06:00
crypto.h mmc: core: Add basic support for inline encryption 2021-02-01 12:02:33 +01:00
debugfs.c mmc: core: Allow more host caps to be modified through debugfs 2025-11-11 17:59:17 +01:00
host.c mmc: core: Cancel SDIO IRQ work before freeing host 2026-09-04 10:27:07 +02:00
host.h mmc: core: Remove checking MMC_CAP_4_BIT_DATA from mmc_host_can_uhs() 2026-03-16 15:46:58 +01:00
Kconfig mmc: block: add RPMB dependency 2024-09-03 14:34:44 +02:00
Makefile mmc: core: Prepare to support SD UHS-II cards 2024-10-14 12:40:10 +02:00
mmc_ops.c mmc: core: add mmc_read_tuning 2025-08-19 14:34:15 +02:00
mmc_ops.h mmc: rename mmc_can_ext_csd() to mmc_card_can_ext_csd() 2025-05-14 16:59:17 +02:00
mmc_test.c mmc: mmc_test: Fix __counted_by handling after kzalloc_flex() conversion 2026-07-06 15:44:16 +02:00
mmc.c mmc: core: Fix host controller programming for fixed driver type 2026-05-11 16:45:48 +02:00
pwrseq_emmc.c mmc: Switch back to struct platform_driver::remove() 2024-10-14 12:29:01 +02:00
pwrseq_sd8787.c mmc: Switch back to struct platform_driver::remove() 2024-10-14 12:29:01 +02:00
pwrseq_simple.c mmc: pwrseq_simple: use gpiod_multi_set_value_cansleep 2025-02-17 14:27:34 +01:00
pwrseq.c mmc: pwrseq: Use device_match_of_node() 2022-12-07 13:22:37 +01:00
pwrseq.h
queue.c for-7.2/block-20260615 2026-06-16 13:02:47 +05:30
queue.h mmc: core: Optimize size of struct mmc_queue_req 2026-04-09 17:49:54 +02:00
quirks.h mmc: core: add NXP IW61x base ID and block size quirk 2026-07-09 14:18:09 +08:00
regulator.c mmc: core: Add infrastructure for undervoltage handling 2025-08-22 12:08:07 +02:00
sd_ops.c mmc: core: Support UHS-II card control and access 2024-10-24 14:22:24 +02:00
sd_ops.h mmc: core: Support UHS-II card control and access 2024-10-24 14:22:24 +02:00
sd_uhs2.c mmc: core: Adjust some error messages for SD UHS-II cards 2025-06-24 12:38:02 +02:00
sd.c mmc: core: Remove unused buffer allocation in sd_enable_cache() 2026-07-06 15:36:41 +02:00
sd.h mmc: core: Support UHS-II card control and access 2024-10-24 14:22:24 +02:00
sdio_bus.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
sdio_bus.h
sdio_cis.c mmc: sdio: fix possible resource leaks in some error paths 2023-02-14 00:06:22 +01:00
sdio_cis.h
sdio_io.c mmc: sdio: Use min3() to simplify sdio_set_block_size() 2026-03-09 14:24:35 +01:00
sdio_irq.c mmc: core: Switch to basic workqueue API for sdio_irq_work 2022-09-14 11:53:47 +02:00
sdio_ops.c
sdio_ops.h
sdio_uart.c mmc: sdio_uart: fix xmit_fifo leak when the port table is full 2026-09-09 13:27:04 +02:00
sdio.c mmc: core: SPI mode remove cmd7 2025-08-19 14:33:37 +02:00
slot-gpio.c mmc: rename mmc_can_gpio_ro() to mmc_host_can_gpio_ro() 2025-05-14 16:59:17 +02:00
slot-gpio.h