mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-09 16:07:17 -04:00
net: lan966x: Fix usage of lan966x->mac_lock when entry is added
To add an entry to the MAC table, it is required first to setup the
entry and then issue a command for the MAC to learn the entry.
So if it happens for two threads to add simultaneously an entry in MAC
table then it would be a race condition.
Fix this by using lan966x->mac_lock to protect the HW access.
Fixes: fc0c3fe748 ("net: lan966x: Add function lan966x_mac_ip_learn()")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Reviewed-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
45533a534a
commit
43243bb319
@@ -75,6 +75,9 @@ static int __lan966x_mac_learn(struct lan966x *lan966x, int pgid,
|
||||
unsigned int vid,
|
||||
enum macaccess_entry_type type)
|
||||
{
|
||||
int ret;
|
||||
|
||||
spin_lock(&lan966x->mac_lock);
|
||||
lan966x_mac_select(lan966x, mac, vid);
|
||||
|
||||
/* Issue a write command */
|
||||
@@ -86,7 +89,10 @@ static int __lan966x_mac_learn(struct lan966x *lan966x, int pgid,
|
||||
ANA_MACACCESS_MAC_TABLE_CMD_SET(MACACCESS_CMD_LEARN),
|
||||
lan966x, ANA_MACACCESS);
|
||||
|
||||
return lan966x_mac_wait_for_completion(lan966x);
|
||||
ret = lan966x_mac_wait_for_completion(lan966x);
|
||||
spin_unlock(&lan966x->mac_lock);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* The mask of the front ports is encoded inside the mac parameter via a call
|
||||
|
||||
Reference in New Issue
Block a user