Commit c17e26dd authored by Hangbin Liu's avatar Hangbin Liu Committed by Jakub Kicinski

team: call RCU read lock when walking the port_list

Before reading the team port list, we need to acquire the RCU read lock.
Also change list_for_each_entry() to list_for_each_entry_rcu().

v2:
repost the patch to net-next and remove fixes flag as this is a cosmetic
change.
Suggested-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Acked-by: default avatarPaolo Abeni <pabeni@redhat.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
parent 5e96cd33
...@@ -2066,7 +2066,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev, ...@@ -2066,7 +2066,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev,
cmd->base.duplex = DUPLEX_UNKNOWN; cmd->base.duplex = DUPLEX_UNKNOWN;
cmd->base.port = PORT_OTHER; cmd->base.port = PORT_OTHER;
list_for_each_entry(port, &team->port_list, list) { rcu_read_lock();
list_for_each_entry_rcu(port, &team->port_list, list) {
if (team_port_txable(port)) { if (team_port_txable(port)) {
if (port->state.speed != SPEED_UNKNOWN) if (port->state.speed != SPEED_UNKNOWN)
speed += port->state.speed; speed += port->state.speed;
...@@ -2075,6 +2076,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev, ...@@ -2075,6 +2076,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev,
cmd->base.duplex = port->state.duplex; cmd->base.duplex = port->state.duplex;
} }
} }
rcu_read_unlock();
cmd->base.speed = speed ? : SPEED_UNKNOWN; cmd->base.speed = speed ? : SPEED_UNKNOWN;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment