diff options
| author | Anfernee Cao <anferneemelokc5@gmail.com> | 2026-10-20 23:36:47 +0800 |
|---|---|---|
| committer | Ulf Hansson <ulfh@kernel.org> | 2026-11-05 18:56:25 +0100 |
| commit | e35e360bd66898a977c296ab71fe4bae17ddceb7 (patch) | |
| tree | b5849e0a375e1fc21ac4893b371e3ea0eeffb05e /include | |
| parent | 2d8927fadbf95e2d2dfa95bcc73882d6e19c2ce4 (diff) | |
mmc: sunxi: fix clock and runtime PM leaks on probe failure
sunxi_mmc_resource_request() enables the bus, card, output and sample
clocks before returning. Several failure paths later in
sunxi_mmc_probe() leave them running:
- If devm_request_threaded_irq() fails, the clocks enabled by
sunxi_mmc_enable() are never disabled.
- If dma_alloc_coherent(), mmc_of_parse() or sunxi_mmc_init_host()
fails, probe only frees the DMA buffer and the mmc_host.
- If mmc_add_host() fails, runtime PM has already been enabled, but
pm_runtime_disable() is never called.
Besides leaking the clocks, this leaves the clock enable counts
unbalanced, so a reprobe (for example after -EPROBE_DEFER) calls
clk_prepare_enable() on the same clocks again.
Disable the IRQ and the clocks in the probe error path, and disable
runtime PM on the mmc_add_host() failure path. Also handle a failure of
devm_request_threaded_irq() in sunxi_mmc_resource_request().
Tested with QEMU's orangepi-pc machine: with forced sunxi_mmc_init_host()
and mmc_add_host() failures the MMC clocks stay disabled in clk_summary,
and a normal probe with an emulated SD card still works.
This issue was found by manual code inspection.
Fixes: 3cbcb16095f9 ("mmc: sunxi: Add driver for SD/MMC hosts found on Allwinner sunxi SoCs")
Fixes: 9a8e1e8cc2c0 ("mmc: sunxi: Add runtime_pm support")
Cc: stable@vger.kernel.org # v4.18+
Signed-off-by: Anfernee Cao <anferneemelokc5@gmail.com>
Signed-off-by: Ulf Hansson <ulfh@kernel.org>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions
