DMA Engine development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jyothi Kumar Seerapu" <jyothi.seerapu@oss.qualcomm.com>
Cc: dmaengine@vger.kernel.org, vkoul@kernel.org, Frank.Li@kernel.org
Subject: Re: [PATCH v2 2/2] i2c: qcom-geni: Add support for I2C High-Speed mode
Date: Sat, 12 Sep 2026 13:24:27 +0000	[thread overview]
Message-ID: <20260912132427.952721F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260912-i2c-hs-v2-2-b0901791e244@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [Critical] Double free and double unmap of the `rx_buf` bounce buffer during multi-message GPI transfers.
--

commit 86b736c2ca3097acfcf4a35074f23d04a9c9f622
Author: Jyothi Kumar Seerapu <jyothi.seerapu@oss.qualcomm.com>

i2c: qcom-geni: Add support for I2C High-Speed mode

Implement I2C High-Speed (HS) mode for the Qualcomm GENI I2C controller,
detecting requests based on 3.4 MHz frequency and configuring timing
parameters accordingly. The patch uses HS-specific opcodes and updates
the GPI DMA configuration with a CONFIG1 TRE to pass timing parameters.

> --- a/drivers/i2c/busses/i2c-qcom-geni.c
> +++ b/drivers/i2c/busses/i2c-qcom-geni.c
[ ... ]
> @@ -883,14 +940,25 @@ static int geni_i2c_gpi_xfer(struct geni_i2c_dev *gi2c, struct i2c_msg msgs[], i
[ ... ]
>  		if (msgs[i].flags & I2C_M_RD) {
> -			ret =  geni_i2c_gpi(gi2c, msgs, &config,
> -					    &rx_addr, &rx_buf, I2C_READ, gi2c->rx_c);
> +			ret =  geni_i2c_gpi(gi2c, msgs, &config, &rx_addr, &rx_buf,
> +					    gi2c->is_hs_mode ? I2C_HS_READ : I2C_READ, gi2c->rx_c);

[Severity: Critical]
This isn't a bug introduced by this patch, but is it possible for a
multi-message transfer to double-free the rx_buf bounce buffer here?

The rx_buf pointer is initialized to NULL outside the loop at the start
of geni_i2c_gpi_xfer().

If a sequence consists of a read message followed by a write message,
iteration 0 (read) will populate rx_buf via geni_i2c_gpi() and then unmap
and free it at the end of the loop using geni_i2c_gpi_unmap().

In iteration 1 (write), this read block is skipped, meaning rx_buf retains
the freed pointer from the previous iteration.

At the end of iteration 1, geni_i2c_gpi_unmap() is called again:

		if (!gi2c->is_tx_multi_desc_xfer)
			geni_i2c_gpi_unmap(gi2c, &msgs[i], tx_buf, tx_addr, rx_buf, rx_addr);

Since rx_buf still contains the pointer from iteration 0, will this result
in a double dma_unmap_single() and double kfree() for the same address?

>  			if (ret)
>  				goto err;
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260912-i2c-hs-v2-0-b0901791e244@oss.qualcomm.com?part=2

  reply	other threads:[~2026-09-12 13:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12 13:04 [PATCH v2 0/2] i2c: Add I2C High-Speed mode support for qcom-geni Jyothi Kumar Seerapu
2026-09-12 13:04 ` [PATCH v2 1/2] dmaengine: qcom-gpi: Add I2C High-Speed mode configuration support Jyothi Kumar Seerapu
2026-09-17 19:20   ` Mukesh Savaliya
2026-09-12 13:04 ` [PATCH v2 2/2] i2c: qcom-geni: Add support for I2C High-Speed mode Jyothi Kumar Seerapu
2026-09-12 13:24   ` sashiko-bot [this message]
2026-09-17 19:21   ` 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=20260912132427.952721F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=jyothi.seerapu@oss.qualcomm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@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