net: ethernet: mtk_eth_soc: fix usage of foe_entry_size
Subsystems (4)
PATCH 2/2 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.
--- drivers/net/ethernet/mediatek/mtk_ppe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/mediatek/mtk_ppe.c +1 -1
@@ -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;
Signature · 1 line
2.37.3
Quoted 9 lines
As
sizeof(hwe->data)can now longer be used as the actual size depends onfoe_entry_size, in commit9d8cb4c096ab02
("net: ethernet:mtk_eth_soc: addfoe_entry_sizetomtk_eth_soc") the use ofsizeof(hwe->data)is hence replaced.However, replacing it with
ppe->eth->soc->foe_entry_sizeis wrong asfoe_entry_sizerepresents the size of the whole descriptor and not just the 'data' field.
Quoted 7 lines
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 <[email protected]>Fixes 9d8cb4c096ab02 ("net: ethernet: mtk_eth_soc: add foe_entry_size to mtk_eth_soc")Signed-off-by Daniel Golle <[email protected]>
Quoted 20 lines
--- drivers/net/ethernet/mediatek/mtk_ppe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/mediatek/mtk_ppe.c +1
-1@@ -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;Signature · 1 line
2.37.3