From: Frank Li <Frank.li@oss.nxp.com>
To: Lee Jones <lee@kernel.org>
Cc: Dong Aisheng <aisheng.dong@nxp.com>,
Andi Shyti <andi.shyti@kernel.org>, Frank Li <Frank.Li@nxp.com>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Carlos Song <carlos.song@nxp.com>, Gao Pan <pandy.gao@nxp.com>,
linux-i2c@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH 01/10] i2c: imx-lpi2c: Clear rx_cmd_buf pointer after freeing in lpi2c_imx_dma_xfer()
Date: Thu, 3 Dec 2026 14:36:31 -0600 [thread overview]
Message-ID: <axHSz6dmMZlkYSjO@SMW015318> (raw)
In-Reply-To: <20261203183214.1939736-2-lee@kernel.org>
On Thu, Dec 03, 2026 at 06:31:05PM +0000, Lee Jones wrote:
> lpi2c_imx->dma persists across transfers. On a DMA read, the
> disable_dma path frees dma->rx_cmd_buf without clearing the pointer.
> If a subsequent DMA read fails in lpi2c_dma_config() or
> lpi2c_dma_submit() before lpi2c_imx_alloc_rx_cmd_buf() runs, the
> cleanup path calls kfree(dma->rx_cmd_buf) a second time on the stale
> pointer.
>
> Reset dma->rx_cmd_buf to NULL immediately after freeing it.
>
> Fixes: a09c8b3f9047 ("i2c: imx-lpi2c: add eDMA mode support for LPI2C")
> Closes: https://sashiko.dev/#/bug/linux-17d925e1-8c99-4efb-a920-2c90ce2b53b5
> Cc: stable@vger.kernel.org
> Signed-off-by: Lee Jones <lee@kernel.org>
> ---
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/i2c/busses/i2c-imx-lpi2c.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
> index ecf2bed01b29..f911b3b7367e 100644
> --- a/drivers/i2c/busses/i2c-imx-lpi2c.c
> +++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
> @@ -1097,8 +1097,10 @@ static int lpi2c_imx_dma_xfer(struct lpi2c_imx_struct *lpi2c_imx,
> /* Disable I2C DMA function */
> writel(0, lpi2c_imx->base + LPI2C_MDER);
>
> - if (dma->dma_msg_flag & I2C_M_RD)
> + if (dma->dma_msg_flag & I2C_M_RD) {
> kfree(dma->rx_cmd_buf);
> + dma->rx_cmd_buf = NULL;
> + }
>
> if (ret)
> i2c_put_dma_safe_msg_buf(dma->dma_buf, msg, false);
> --
> 2.56.1.911.g883d8bcb20-goog
>
>
next prev parent reply other threads:[~2026-12-03 20:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261203183214.1939736-1-lee@kernel.org>
2026-12-03 18:31 ` [PATCH 01/10] i2c: imx-lpi2c: Clear rx_cmd_buf pointer after freeing in lpi2c_imx_dma_xfer() Lee Jones
2026-12-03 20:36 ` Frank Li [this message]
2026-12-03 18:31 ` [PATCH 05/10] i2c: stm32f7: Prevent duplicate execution of stm32f7_i2c_dma_callback() Lee Jones
2026-12-03 18:31 ` [PATCH 06/10] i2c: stm32f7: Allocate smbus_buf separately for DMA safety Lee Jones
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=axHSz6dmMZlkYSjO@SMW015318 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=andi.shyti@kernel.org \
--cc=carlos.song@nxp.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=lee@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pandy.gao@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=stable@vger.kernel.org \
/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