]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
team: call RCU read lock when walking the port_list
authorHangbin Liu <liuhangbin@gmail.com>
Wed, 9 Oct 2019 12:18:28 +0000 (20:18 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 31 Dec 2019 15:43:54 +0000 (16:43 +0100)
[ Upstream commit c17e26ddc79596230834345be80fcad6c619e9ec ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/team/team.c

index 8156b33ee3e7919188127c9ed7e732d89501eb66..ca70a1d840eb38522a20a47b4404a325e7aeb956 100644 (file)
@@ -2074,7 +2074,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;
@@ -2083,6 +2084,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;