]>
Commit | Line | Data |
---|---|---|
7a674766 GKH |
1 | From 83ac5bd697e4fde6357fe4611f7f03edc547f8a9 Mon Sep 17 00:00:00 2001 |
2 | From: Jiri Pirko <jiri@resnulli.us> | |
3 | Date: Sat, 8 Jun 2013 15:00:53 +0200 | |
4 | Subject: team: check return value of team_get_port_by_index_rcu() for NULL | |
5 | ||
6 | From: Jiri Pirko <jiri@resnulli.us> | |
7 | ||
8 | [ Upstream commit 76c455decbbad31de21c727edb184a963f42b40b ] | |
9 | ||
10 | team_get_port_by_index_rcu() might return NULL due to race between port | |
11 | removal and skb tx path. Panic is easily triggeable when txing packets | |
12 | and adding/removing port in a loop. | |
13 | ||
14 | introduced by commit 3d249d4ca "net: introduce ethernet teaming device" | |
15 | and commit 753f993911b "team: introduce random mode" (for random mode) | |
16 | ||
17 | Signed-off-by: Jiri Pirko <jiri@resnulli.us> | |
18 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
19 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
20 | --- | |
21 | drivers/net/team/team_mode_roundrobin.c | 2 ++ | |
22 | 1 file changed, 2 insertions(+) | |
23 | ||
24 | --- a/drivers/net/team/team_mode_roundrobin.c | |
25 | +++ b/drivers/net/team/team_mode_roundrobin.c | |
26 | @@ -52,6 +52,8 @@ static bool rr_transmit(struct team *tea | |
27 | ||
28 | port_index = rr_priv(team)->sent_packets++ % team->port_count; | |
29 | port = team_get_port_by_index_rcu(team, port_index); | |
30 | + if (unlikely(!port)) | |
31 | + goto drop; | |
32 | port = __get_first_port_up(team, port); | |
33 | if (unlikely(!port)) | |
34 | goto drop; |