bb02f401a2d6fa00293da4242b6d78bf00215a7c
[openwrt/staging/thess.git] /
1 From fcf14c2c5deae8f8c3d25530bab10856f63f8a63 Mon Sep 17 00:00:00 2001
2 From: Daniel Golle <daniel@makrotopia.org>
3 Date: Sun, 25 Sep 2022 15:18:54 +0100
4 Subject: [PATCH 2/2] net: ethernet: mtk_eth_soc: fix usage of foe_entry_size
5 To: linux-mediatek@lists.infradead.org,
6 netdev@vger.kernel.org,
7 Lorenzo Bianconi <lorenzo@kernel.org>
8 Cc: Sujuan Chen <sujuan.chen@mediatek.com>,
9 Bo Jiao <Bo.Jiao@mediatek.com>,
10 Felix Fietkau <nbd@nbd.name>,
11 John Crispin <john@phrozen.org>,
12 Sean Wang <sean.wang@mediatek.com>,
13 Mark Lee <Mark-MC.Lee@mediatek.com>,
14 David S. Miller <davem@davemloft.net>,
15 Eric Dumazet <edumazet@google.com>,
16 Jakub Kicinski <kuba@kernel.org>,
17 Paolo Abeni <pabeni@redhat.com>,
18 Matthias Brugger <matthias.bgg@gmail.com>,
19 Chen Minqiang <ptpt52@gmail.com>
20
21 As sizeof(hwe->data) can now longer be used as the actual size depends
22 on foe_entry_size, in commit 9d8cb4c096ab02
23 ("net: ethernet: mtk_eth_soc: add foe_entry_size to mtk_eth_soc") the
24 use of sizeof(hwe->data) is hence replaced.
25 However, replacing it with ppe->eth->soc->foe_entry_size is wrong as
26 foe_entry_size represents the size of the whole descriptor and not just
27 the 'data' field.
28 Fix this by subtracing the size of the only other field in the struct
29 'ib1', so we actually end up with the correct size to be copied to the
30 data field.
31
32 Reported-by: Chen Minqiang <ptpt52@gmail.com>
33 Fixes: 9d8cb4c096ab02 ("net: ethernet: mtk_eth_soc: add foe_entry_size to mtk_eth_soc")
34 Signed-off-by: Daniel Golle <daniel@makrotopia.org>
35 ---
36 drivers/net/ethernet/mediatek/mtk_ppe.c | 2 +-
37 1 file changed, 1 insertion(+), 1 deletion(-)
38
39 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
40 +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
41 @@ -547,7 +547,7 @@ __mtk_foe_entry_commit(struct mtk_ppe *p
42 }
43
44 hwe = mtk_foe_get_entry(ppe, hash);
45 - memcpy(&hwe->data, &entry->data, eth->soc->foe_entry_size);
46 + memcpy(&hwe->data, &entry->data, eth->soc->foe_entry_size - sizeof(hwe->ib1));
47 wmb();
48 hwe->ib1 = entry->ib1;
49