| Message ID | 20260827-i2c-dma-channel-leak-v1-2-271d4adc03a0@cherr.cc |
|---|---|
| State | New |
| Headers | show |
| Series | i2c: fix DMA channel leaks on probe error and remove | expand |
On Thu, Aug 27, 2026 at 11:43:02PM +0800, Shengzhuo Wei wrote: > i2c_imx_dma_request() acquires exclusive tx/rx DMA channels and is > optional: on errors other than -EPROBE_DEFER the driver falls back to > PIO mode and probe continues. If i2c_add_numbered_adapter() then fails, > probe returns through clk_notifier_unregister without releasing the > channels, because the remove callback is not invoked after a failed > probe. > > Release the channels on the probe error path, mirroring > i2c_imx_remove(). > > Fixes: ce1a78840ff7 ("i2c: imx: add DMA support for freescale i2c driver") > Cc: stable@vger.kernel.org > Signed-off-by: Shengzhuo Wei <me@cherr.cc> > Assisted-by: GLM:5.3 Nit: signed-off-by should be last tag Reviewed-by: Frank Li <Frank.Li@nxp.com> > --- > drivers/i2c/busses/i2c-imx.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c > index 19ec056b00af..c24d9201a60e 100644 > --- a/drivers/i2c/busses/i2c-imx.c > +++ b/drivers/i2c/busses/i2c-imx.c > @@ -1880,6 +1880,8 @@ static int i2c_imx_probe(struct platform_device *pdev) > > clk_notifier_unregister: > clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb); > + if (i2c_imx->dma) > + i2c_imx_dma_free(i2c_imx); > free_irq(irq, i2c_imx); > rpm_disable: > pm_runtime_put_noidle(&pdev->dev); > > -- > 2.47.3 >
diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c index 19ec056b00af..c24d9201a60e 100644 --- a/drivers/i2c/busses/i2c-imx.c +++ b/drivers/i2c/busses/i2c-imx.c @@ -1880,6 +1880,8 @@ static int i2c_imx_probe(struct platform_device *pdev) clk_notifier_unregister: clk_notifier_unregister(i2c_imx->clk, &i2c_imx->clk_change_nb); + if (i2c_imx->dma) + i2c_imx_dma_free(i2c_imx); free_irq(irq, i2c_imx); rpm_disable: pm_runtime_put_noidle(&pdev->dev);
i2c_imx_dma_request() acquires exclusive tx/rx DMA channels and is optional: on errors other than -EPROBE_DEFER the driver falls back to PIO mode and probe continues. If i2c_add_numbered_adapter() then fails, probe returns through clk_notifier_unregister without releasing the channels, because the remove callback is not invoked after a failed probe. Release the channels on the probe error path, mirroring i2c_imx_remove(). Fixes: ce1a78840ff7 ("i2c: imx: add DMA support for freescale i2c driver") Cc: stable@vger.kernel.org Signed-off-by: Shengzhuo Wei <me@cherr.cc> Assisted-by: GLM:5.3 --- drivers/i2c/busses/i2c-imx.c | 2 ++ 1 file changed, 2 insertions(+)