Skip to content

Commit cebc07d

Browse files
Wolfram SangWolfram Sang
authored andcommitted
i2c: sh_mobile: fix leak when using DMA bounce buffer
We only freed the bounce buffer after successful DMA, missing the cases where DMA setup may have gone wrong. Use a better location which always gets called after each message and use 'stop_after_dma' as a flag for a successful transfer. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
1 parent 531db50 commit cebc07d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/i2c/busses/i2c-sh_mobile.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,6 @@ static void sh_mobile_i2c_dma_callback(void *data)
507507
pd->pos = pd->msg->len;
508508
pd->stop_after_dma = true;
509509

510-
i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg, true);
511-
512510
iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE);
513511
}
514512

@@ -706,6 +704,10 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
706704
timeout = wait_event_timeout(pd->wait,
707705
pd->sr & (ICSR_TACK | SW_DONE),
708706
adapter->timeout);
707+
708+
/* 'stop_after_dma' tells if DMA transfer was complete */
709+
i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg, pd->stop_after_dma);
710+
709711
if (!timeout) {
710712
dev_err(pd->dev, "Transfer request timed out\n");
711713
if (pd->dma_direction != DMA_NONE)

0 commit comments

Comments
 (0)