Thread View: linux.kernel.netdev
3 messages
3 total messages
Started by Thomas Fourier
Thu, 15 Oct 2026 14:01
[PATCH net-next] net: ethernet: mtk_wed: Fix dma_unmap_single() size
Author: Thomas Fourier
Date: Thu, 15 Oct 2026 14:01
Date: Thu, 15 Oct 2026 14:01
39 lines
9977 bytes
9977 bytes
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.
Fixes: 799684448e3e ("net: ethernet: mtk_wed: introduce wed wo support")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
drivers/net/ethernet/mediatek/mtk_wed_wo.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_wed_wo.c b/drivers/net/ethernet/mediatek/mtk_wed_wo.c
index 7063c78bd35f..4f720ec53e20 100644
--- a/drivers/net/ethernet/mediatek/mtk_wed_wo.c
+++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.c
@@ -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;
--
2.53.0
Re: [PATCH net-next] net: ethernet: mtk_wed: Fix dma_unmap_single() size
Author: Lorenzo Bianconi
Date: Thu, 15 Oct 2026 14:19
Date: Thu, 15 Oct 2026 14:19
66 lines
8132 bytes
8132 bytes
--bf2LvNtCjkzeEFGh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
> 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).
>=20
> Change the size to q->buf_size.
>=20
> This was discovered with static analysis and was only compile-tested.
>=20
> Fixes: 799684448e3e ("net: ethernet: mtk_wed: introduce wed wo support")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
> drivers/net/ethernet/mediatek/mtk_wed_wo.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>=20
> diff --git a/drivers/net/ethernet/mediatek/mtk_wed_wo.c b/drivers/net/eth=
ernet/mediatek/mtk_wed_wo.c
> index 7063c78bd35f..4f720ec53e20 100644
> --- a/drivers/net/ethernet/mediatek/mtk_wed_wo.c
> +++ b/drivers/net/ethernet/mediatek/mtk_wed_wo.c
> @@ -99,7 +99,6 @@ static void *
> mtk_wed_wo_dequeue(struct mtk_wed_wo *wo, struct mtk_wed_wo_queue *q, u3=
2 *len,
> bool flush)
> {
> - int buf_len =3D SKB_WITH_OVERHEAD(q->buf_size);
> int index =3D (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 =3D 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:
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
> DMA_FROM_DEVICE);
> entry->buf =3D NULL;
> =20
> --=20
> 2.53.0
>=20
--bf2LvNtCjkzeEFGh
Content-Type: application/pgp-signature; name=signature.asc
-----BEGIN PGP SIGNATURE-----
iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCatDg1QAKCRA6cBh0uS2t
rAHDAQCBk2/JP1GlWzVrZmGmNrnZUmPT6fHOUTTZRcN+7YPm+gD9GGJ0a5/HxB8d
rhhirUOm4xPSbbOd9R0UefDOqX6KUwQ=
=PNQo
-----END PGP SIGNATURE-----
--bf2LvNtCjkzeEFGh--
Re: [PATCH net-next] net: ethernet: mtk_wed: Fix dma_unmap_single() size
Author: patchwork-bot+netdevbpf
Date: Tue, 20 Oct 2026 19:00
Date: Tue, 20 Oct 2026 19:00
24 lines
8753 bytes
8753 bytes
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Thu, 15 Oct 2026 16:01:09 +0200 you wrote:
> 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.
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads