net: ethernet: mtk_wed: Fix dma_unmap_single() size
Subsystems (4)
PATCH 1/1 net: ethernet: mtk_wed: Fix dma_unmap_single() size
In mtk_wed_wo_queue_refill(), the entry->buf is DMA mapped with length q->buf_size which saved in entry->len. However, in mtk_wed_wo_dequeue(), the same buffer is DMA unmapped with length buf_len which is set to SKB_WITH_OVERHEAD(q->buf_size).
Change the size to q->buf_size.
This was discovered with static analysis and was only compile-tested.
--- drivers/net/ethernet/mediatek/mtk_wed_wo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/ethernet/mediatek/mtk_wed_wo.c +1 -2
@@ -99,7 +99,6 @@ static void * mtk_wed_wo_dequeue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, u32 *len, bool flush) { - int buf_len = SKB_WITH_OVERHEAD(q->buf_size); int index = (q->tail + 1) % q->n_desc;struct mtk_wed_wo_queue_entry *entry;struct mtk_wed_wo_queue_desc *desc;
@@ -123,7 +122,7 @@ mtk_wed_wo_dequeue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, u32 *len, *len =FIELD_GET (MTK_WED_WO_CTL_SD_LEN0 ,le32_to_cpu (READ_ONCE (desc->ctrl)));if (buf) -dma_unmap_single (wo->hw->dev, entry->addr, buf_len, +dma_unmap_single (wo->hw->dev, entry->addr, q->buf_size,DMA_FROM_DEVICE ); entry->buf =NULL ;
Signature · 1 line
2.53.0
Quoted 28 lines
In
mtk_wed_wo_queue_refill(), theentry->bufis DMA mapped with lengthq->buf_sizewhich saved inentry->len. However, inmtk_wed_wo_dequeue(), the same buffer is DMA unmapped with lengthbuf_lenwhich is set toSKB_WITH_OVERHEAD(q->buf_size).Change the size to
q->buf_size.This was discovered with static analysis and was only compile-tested.
Fixes 799684448e3e ("net: ethernet: mtk_wed: introduce wed wo support")Signed-off-by Thomas Fourier <[email protected]>--- drivers/net/ethernet/mediatek/mtk_wed_wo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)drivers/net/ethernet/mediatek/mtk_wed_wo.c +0
-1@@ -99,7 +99,6 @@ static void * mtk_wed_wo_dequeue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, u32 *len, bool flush) { - int buf_len = SKB_WITH_OVERHEAD(q->buf_size); int index = (q->tail + 1) % q->n_desc;struct mtk_wed_wo_queue_entry *entry;struct mtk_wed_wo_queue_desc *desc;
drivers/net/ethernet/mediatek/mtk_wed_wo.c mtk_wed_wo_dequeue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, u32 *len, · line 125
Quoted 5 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.c +1
-1@@ -123,7 +122,7 @@ mtk_wed_wo_dequeue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, u32 *len, *len =FIELD_GET (MTK_WED_WO_CTL_SD_LEN0 ,le32_to_cpu (READ_ONCE (desc->ctrl)));if (buf) - dma_unmap_single(wo->hw->dev, entry->addr, buf_len, + dma_unmap_single(wo->hw->dev, entry->addr, q->buf_size,
I guess you can use entry->len here to align with the tx side. Anyway:
Quoted 6 lines
drivers/net/ethernet/mediatek/mtk_wed_wo.c +0
-0DMA_FROM_DEVICE); entry->buf =NULL ;Signature · 1 line
2.53.0
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Thu, 15 Oct 2026 16:01:09 +0200 you wrote:
In
mtk_wed_wo_queue_refill(), theentry->bufis DMA mapped with lengthq->buf_sizewhich saved inentry->len. However, inmtk_wed_wo_dequeue(), the same buffer is DMA unmapped with lengthbuf_lenwhich is set toSKB_WITH_OVERHEAD(q->buf_size).Change the size to
q->buf_size.[...]
Here is the summary with links:
- [net-next] net: ethernet: mtk_wed: Fix dma_unmap_single() size
https://git.kernel.org/netdev/net-next/c/ff5a2a7acec1
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html