From: sashiko-bot@kernel.org
To: "Shengzhuo Wei" <me@cherr.cc>
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH 2/3] i2c: imx: release DMA channels on probe error
Date: Thu, 27 Aug 2026 15:56:13 +0000 [thread overview]
Message-ID: <20260827155614.1BFA71F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827-i2c-dma-channel-leak-v1-2-271d4adc03a0@cherr.cc>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The IRQ handler accesses hardware registers without verifying if the device is runtime active, and the runtime suspend callback lacks `synchronize_irq()`. This combination causes system crashes or invalid reads on shared IRQ lines.
--
commit bd798c45679ae67bd4a370c03b96a207ed6bc4a9
Author: Shengzhuo Wei <me@cherr.cc>
i2c: imx: release DMA channels on probe error
i2c_imx_dma_request() acquires exclusive tx/rx DMA channels and is optional.
If i2c_add_numbered_adapter() then fails, probe returns without releasing
the channels. This commit ensures the channels are released on the probe
error path.
Fixes: ce1a78840ff7 ("i2c: imx: add DMA support for freescale i2c driver")
Cc: stable@vger.kernel.org
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 19ec056b00afe..c24d9201a60e8 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);
[Severity: High]
This isn't a bug introduced by this patch, but since we're modifying the
probe and IRQ cleanup paths, could this driver crash due to unclocked
register reads if the IRQ is shared?
Looking at the driver, the IRQ is registered as shared during probe:
drivers/i2c/busses/i2c-imx.c:i2c_imx_probe() {
...
ret = request_irq(irq, i2c_imx_isr, IRQF_SHARED | IRQF_NO_SUSPEND,
pdev->name, i2c_imx);
...
}
However, the runtime suspend callback disables the clock without ensuring
no ISR is running:
drivers/i2c/busses/i2c-imx.c:i2c_imx_runtime_suspend() {
...
clk_disable(i2c_imx->clk);
...
}
If another device sharing the same interrupt line fires while this device
is runtime suspended, i2c_imx_isr() is called and unconditionally reads from
the unclocked hardware:
drivers/i2c/busses/i2c-imx.c:i2c_imx_isr() {
...
status = imx_i2c_read_reg(i2c_imx, IMX_I2C_I2SR);
...
}
Should the runtime suspend callback use synchronize_irq(), and the ISR use
pm_runtime_get_if_active() before accessing hardware registers to prevent
these invalid reads or system crashes?
> rpm_disable:
> pm_runtime_put_noidle(&pdev->dev);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827-i2c-dma-channel-leak-v1-0-271d4adc03a0@cherr.cc?part=2
next prev parent reply other threads:[~2026-08-27 15:56 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 15:43 [PATCH 0/3] i2c: fix DMA channel leaks on probe error and remove Shengzhuo Wei
2026-08-27 15:43 ` [PATCH 1/3] i2c: at91: release DMA channels on remove and probe error Shengzhuo Wei
2026-08-27 15:55 ` sashiko-bot
2026-08-31 9:11 ` Mukesh Savaliya
2026-08-27 15:43 ` [PATCH 2/3] i2c: imx: release DMA channels on " Shengzhuo Wei
2026-08-27 15:56 ` sashiko-bot [this message]
2026-08-27 16:01 ` Frank Li
2026-08-27 15:43 ` [PATCH 3/3] i2c: qcom-geni: " Shengzhuo Wei
2026-08-27 15:57 ` sashiko-bot
2026-08-31 7:20 ` Konrad Dybcio
2026-08-31 8:51 ` Mukesh Savaliya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260827155614.1BFA71F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=Frank.Li@kernel.org \
--cc=imx@lists.linux.dev \
--cc=me@cherr.cc \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox