From: Daniel Golle Date: Sun, 25 Sep 2022 14:48:43 +0000 (+0100) Subject: net: ethernet: mtk_eth_soc: fix usage of foe_entry_size X-Git-Tag: v6.6.17~6504^2~91 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=454b20e19322e6a9375cbaad68fff3c93bd27716;p=platform%2Fkernel%2Flinux-rpi.git net: ethernet: mtk_eth_soc: fix usage of foe_entry_size As sizeof(hwe->data) can now longer be used as the actual size depends on foe_entry_size, in commit 9d8cb4c096ab02 ("net: ethernet: mtk_eth_soc: add foe_entry_size to mtk_eth_soc") the use of sizeof(hwe->data) is hence replaced. However, replacing it with ppe->eth->soc->foe_entry_size is wrong as foe_entry_size represents the size of the whole descriptor and not just the 'data' field. Fix this by subtracing the size of the only other field in the struct 'ib1', so we actually end up with the correct size to be copied to the data field. Reported-by: Chen Minqiang Fixes: 9d8cb4c096ab02 ("net: ethernet: mtk_eth_soc: add foe_entry_size to mtk_eth_soc") Signed-off-by: Daniel Golle Acked-by: Lorenzo Bianconi Link: https://lore.kernel.org/r/YzBqPIgQR2gLrPoK@makrotopia.org Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c index 4ea2b34..887f430 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c @@ -547,7 +547,7 @@ __mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry, } hwe = mtk_foe_get_entry(ppe, hash); - memcpy(&hwe->data, &entry->data, eth->soc->foe_entry_size); + memcpy(&hwe->data, &entry->data, eth->soc->foe_entry_size - sizeof(hwe->ib1)); wmb(); hwe->ib1 = entry->ib1;