public inbox for linux-aspeed@lists.ozlabs.org
 help / color / mirror / Atom feed
* [PATCH] i2c: aspeed: Avoid accessing freed buffers during i2c transfers.
@ 2023-07-28 12:24 Lixue Liang
  2023-07-31  4:21 ` Joel Stanley
  2023-08-05 10:10 ` Andi Shyti
  0 siblings, 2 replies; 7+ messages in thread
From: Lixue Liang @ 2023-07-28 12:24 UTC (permalink / raw)
  To: linux-aspeed

From: Lixue Liang <lianglixue@greatwall.com.cn>

After waiting for the transmission timeout, the I2C controller will
continue to transmit data when the bus is idle. Clearing bus->msg will
avoid kernel panic when accessing the freed msg->buf in
aspeed_i2c_master_irq.

Signed-off-by: Lixue Liang <lianglixue@greatwall.com.cn>
---
 drivers/i2c/busses/i2c-aspeed.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c
index 2e5acfeb76c8..c83057497e26 100644
--- a/drivers/i2c/busses/i2c-aspeed.c
+++ b/drivers/i2c/busses/i2c-aspeed.c
@@ -713,6 +713,8 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,
 		spin_lock_irqsave(&bus->lock, flags);
 		if (bus->master_state == ASPEED_I2C_MASTER_PENDING)
 			bus->master_state = ASPEED_I2C_MASTER_INACTIVE;
+
+		bus->msgs = NULL;
 		spin_unlock_irqrestore(&bus->lock, flags);
 
 		return -ETIMEDOUT;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-10  1:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-28 12:24 [PATCH] i2c: aspeed: Avoid accessing freed buffers during i2c transfers Lixue Liang
2023-07-31  4:21 ` Joel Stanley
2023-07-31  6:10   ` Lei YU
2023-08-02 13:41     ` Eddie James
2023-08-10  1:30       ` 梁礼学
2023-08-05 10:10 ` Andi Shyti
2023-08-10  1:14   ` 梁礼学

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox