Linux I2C development
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: lee@kernel.org,
	"Mukesh Kumar Savaliya" <mukesh.savaliya@oss.qualcomm.com>,
	"Viken Dadhaniya" <viken.dadhaniya@oss.qualcomm.com>,
	"Andi Shyti" <andi.shyti@kernel.org>,
	"Sumit Semwal" <sumit.semwal@linaro.org>,
	"Christian König" <christian.koenig@amd.com>,
	"Philipp Stanner" <phasta@kernel.org>,
	"Roja Rani Yarubandi" <rojay@codeaurora.org>,
	"Akash Asthana" <akashast@codeaurora.org>,
	"Wolfram Sang" <wsa+renesas@sang-engineering.com>,
	linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org,
	linaro-mm-sig@lists.linaro.org
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH 02/10] i2c: qcom-geni: Clear dma_buf pointer after releasing DMA buffer
Date: Thu,  3 Dec 2026 18:31:06 +0000	[thread overview]
Message-ID: <20261203183214.1939736-3-lee@kernel.org> (raw)
In-Reply-To: <20261203183214.1939736-1-lee@kernel.org>

geni_i2c_rx_msg_cleanup() and geni_i2c_tx_msg_cleanup() release
gi2c->dma_buf without setting it back to NULL.  If a subsequent
transfer fails geni_se_{rx,tx}_dma_prep() and falls back to FIFO mode,
gi2c->dma_buf retains the stale pointer from the previous transfer,
causing the cleanup helper to unprepare and free the buffer a second
time.

Set gi2c->dma_buf to NULL after releasing it in both cleanup functions.

Fixes: 357ee8841d0b ("i2c: qcom-geni: Store DMA mapping data in geni_i2c_dev struct")
Closes: https://sashiko.dev/#/bug/linux-d60db3da-ca85-40ac-8a6c-62b1d80be7ac
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
 drivers/i2c/busses/i2c-qcom-geni.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c
index 926bc484ead2..6779719bbefa 100644
--- a/drivers/i2c/busses/i2c-qcom-geni.c
+++ b/drivers/i2c/busses/i2c-qcom-geni.c
@@ -505,6 +505,7 @@ static void geni_i2c_rx_msg_cleanup(struct geni_i2c_dev *gi2c,
 			geni_i2c_rx_fsm_rst(gi2c);
 		geni_se_rx_dma_unprep(&gi2c->se, gi2c->dma_addr, gi2c->xfer_len);
 		i2c_put_dma_safe_msg_buf(gi2c->dma_buf, cur, !gi2c->err);
+		gi2c->dma_buf = NULL;
 	}
 }
 
@@ -517,6 +518,7 @@ static void geni_i2c_tx_msg_cleanup(struct geni_i2c_dev *gi2c,
 			geni_i2c_tx_fsm_rst(gi2c);
 		geni_se_tx_dma_unprep(&gi2c->se, gi2c->dma_addr, gi2c->xfer_len);
 		i2c_put_dma_safe_msg_buf(gi2c->dma_buf, cur, !gi2c->err);
+		gi2c->dma_buf = NULL;
 	}
 }
 
-- 
2.56.1.911.g883d8bcb20-goog


  parent reply	other threads:[~2026-12-03 18:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 18:31 [PATCH 00/10] i2c: Fix Critical and High issues reported by Sashiko Lee Jones
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 18:31 ` Lee Jones [this message]
2026-12-03 18:31 ` [PATCH 03/10] i2c: sh_mobile: Terminate DMA before freeing bounce buffer in sh_mobile_xfer() Lee Jones
2026-12-03 18:31 ` [PATCH 04/10] i2c: omap: Check buf_len before buffer accesses in data transfer helpers Lee Jones
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
2026-12-03 18:31 ` [PATCH 07/10] i2c: usbio: Validate full reply length in split-read loop Lee Jones
2026-12-03 18:31 ` [PATCH 08/10] i2c: amd-mp2: Synchronise IRQ completion with command timeout Lee Jones
2026-12-03 18:31 ` [PATCH 09/10] i2c: mlxbf: Reject zero-length SMBus reads to prevent stack overflow Lee Jones
2026-12-03 18:31 ` [PATCH 10/10] i2c: octeon: Guard to_pci_dev() with dev_is_pci() in octeon_i2c_set_clock() 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=20261203183214.1939736-3-lee@kernel.org \
    --to=lee@kernel.org \
    --cc=akashast@codeaurora.org \
    --cc=andi.shyti@kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linaro-mm-sig@lists.linaro.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mukesh.savaliya@oss.qualcomm.com \
    --cc=phasta@kernel.org \
    --cc=rojay@codeaurora.org \
    --cc=stable@vger.kernel.org \
    --cc=sumit.semwal@linaro.org \
    --cc=viken.dadhaniya@oss.qualcomm.com \
    --cc=wsa+renesas@sang-engineering.com \
    /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