Skip to content

Commit

Permalink
team: call RCU read lock when walking the port_list
Browse files Browse the repository at this point in the history
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: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Paolo Abeni <pabeni@redhat.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
  • Loading branch information
Hangbin Liu authored and Jakub Kicinski committed Oct 10, 2019
1 parent 5e96cd3 commit c17e26d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/net/team/team.c
Original file line number Diff line number Diff line change
Expand Up @@ -2066,7 +2066,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev,
cmd->base.duplex = DUPLEX_UNKNOWN;
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 (port->state.speed != SPEED_UNKNOWN)
speed += port->state.speed;
Expand All @@ -2075,6 +2076,8 @@ static int team_ethtool_get_link_ksettings(struct net_device *dev,
cmd->base.duplex = port->state.duplex;
}
}
rcu_read_unlock();

cmd->base.speed = speed ? : SPEED_UNKNOWN;

return 0;
Expand Down

0 comments on commit c17e26d

Please sign in to comment.