summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiri Pirko <jiri@resnulli.us>2013-06-08 15:00:54 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-06-27 10:39:06 -0700
commit1cadc4351e3bb9a55460139fb8cdb00266c45e24 (patch)
treec2bc027b97b3897c0296588dd48aadf654bc30f2
parent397ab236f5273dfc2ab81ec637a61b3eb22bfc08 (diff)
team: move add to port list before port enablement
[ Upstream commit 72df935d985c1575ed44ad2c8c653b28147993fa ] team_port_enable() adds port to port_hashlist. Reader sees port in team_get_port_by_index_rcu() and returns it, but team_get_first_port_txable_rcu() tries to go through port_list, where the port is not inserted yet -> NULL pointer dereference. Fix this by reordering port_list and port_hashlist insertion. Panic is easily triggeable when txing packets and adding/removing port in a loop. Introduced by commit 3d249d4c "net: introduce ethernet teaming device" Signed-off-by: Jiri Pirko <jiri@resnulli.us> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/net/team/team.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index bf3419297875..0017b67361fc 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1079,8 +1079,8 @@ static int team_port_add(struct team *team, struct net_device *port_dev)
}
port->index = -1;
- team_port_enable(team, port);
list_add_tail_rcu(&port->list, &team->port_list);
+ team_port_enable(team, port);
__team_compute_features(team);
__team_port_change_port_added(port, !!netif_carrier_ok(port_dev));
__team_options_change_check(team);