i2c: qup: Release DMA channels if interconnect lookup fails
Subsystems (2)
PATCH 1/1 i2c: qup: Release DMA channels if interconnect lookup fails
qup_i2c_probe() acquires both BAM DMA channels before getting its interconnect path. If devm_of_icc_get() fails, the direct return skips fail_dma and leaks both channels, including when probe is deferred. A later probe can no longer acquire those channels.
Keep the reported error code and jump to fail_dma to release the channels. This avoids the clock and MMIO cleanup, which have not been initialized at this point.
---
Based on linux-next next-20261102 (2637bdec0535).
Compile-tested: arm64, GCC 14.2.0, W=1, CONFIG_OF_DYNAMIC=y. COMPILE_TEST=y.
Baseline and patched target objects built from this exact base. No full kernel/module-link, hardware or runtime test was performed. AI assistance was used for analysis and patch preparation.
The error needs an interconnect provider failure/defer after DMA setup. No in-tree QUP I2C DT with the needed interconnects property was identified.
drivers/i2c/busses/i2c-qup.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/i2c/busses/i2c-qup.c +5 -3
@@ -1786,9 +1786,11 @@ static int qup_i2c_probe(struct platform_device *pdev) qup->is_dma = true; qup->icc_path =devm_of_icc_get (&pdev->dev,NULL ); -if (IS_ERR (qup->icc_path)) -return dev_err_probe (&pdev->dev,PTR_ERR (qup->icc_path), -"failed to get interconnect path\n" ); +if (IS_ERR (qup->icc_path)) { + ret =dev_err_probe (&pdev->dev,PTR_ERR (qup->icc_path), +"failed to get interconnect path\n" ); + goto fail_dma; + } } nodma:
base-commit: 2637bdec0535a2044cd830eba9a79363651d9043
Quoted 5 lines · Yige Jiang
qup_i2c_probe()acquires both BAM DMA channels before getting its interconnect path. Ifdevm_of_icc_get()fails, the direct return skipsfail_dmaand leaks both channels, including when probe is deferred. A later probe can no longer acquire those channels.
Quoted 7 lines
Keep the reported error code and jump to
fail_dmato release the channels. This avoids the clock and MMIO cleanup, which have not been initialized at this point.Fixes d4f35233a634 ("i2c: qup: Vote for interconnect bandwidth to DRAM")Signed-off-by Yige Jiang <[email protected]>---
Can se use devm_dma_request_chan() instead?
Konrad