Skip to content

Commit

Permalink
team: check return value of team_get_port_by_index_rcu() for NULL
Browse files Browse the repository at this point in the history
team_get_port_by_index_rcu() might return NULL due to race between port
removal and skb tx path. Panic is easily triggeable when txing packets
and adding/removing port in a loop.

introduced by commit 3d249d4 "net: introduce ethernet teaming device"
and commit 753f993 "team: introduce random mode" (for random mode)

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Jun 12, 2013
1 parent 19a6afb commit 76c455d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/net/team/team_mode_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ static bool rnd_transmit(struct team *team, struct sk_buff *skb)

port_index = random_N(team->en_port_count);
port = team_get_port_by_index_rcu(team, port_index);
if (unlikely(!port))
goto drop;
port = team_get_first_port_txable_rcu(team, port);
if (unlikely(!port))
goto drop;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/team/team_mode_roundrobin.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ static bool rr_transmit(struct team *team, struct sk_buff *skb)

port_index = rr_priv(team)->sent_packets++ % team->en_port_count;
port = team_get_port_by_index_rcu(team, port_index);
if (unlikely(!port))
goto drop;
port = team_get_first_port_txable_rcu(team, port);
if (unlikely(!port))
goto drop;
Expand Down

0 comments on commit 76c455d

Please sign in to comment.