Skip to content

Commit

Permalink
net_sched: hold tcf_lock in netdevice notifier
Browse files Browse the repository at this point in the history
We modify mirred action (m->tcfm_dev) in netdev event, we need to
prevent on-going mirred actions from reading freed m->tcfm_dev.
So we need to acquire this spin lock.

Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Cong Wang authored and David S. Miller committed Jul 21, 2014
1 parent e81fbf6 commit 224e923
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/sched/act_mirred.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,12 @@ static int mirred_device_event(struct notifier_block *unused,

if (event == NETDEV_UNREGISTER)
list_for_each_entry(m, &mirred_list, tcfm_list) {
spin_lock_bh(&m->tcf_lock);
if (m->tcfm_dev == dev) {
dev_put(dev);
m->tcfm_dev = NULL;
}
spin_unlock_bh(&m->tcf_lock);
}

return NOTIFY_DONE;
Expand Down

0 comments on commit 224e923

Please sign in to comment.