Commit 224e923c authored by Cong Wang's avatar Cong Wang Committed by David S. Miller

net_sched: hold tcf_lock in netdevice notifier

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: default avatarCong Wang <cwang@twopensource.com>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e81fbf6c
...@@ -218,10 +218,12 @@ static int mirred_device_event(struct notifier_block *unused, ...@@ -218,10 +218,12 @@ static int mirred_device_event(struct notifier_block *unused,
if (event == NETDEV_UNREGISTER) if (event == NETDEV_UNREGISTER)
list_for_each_entry(m, &mirred_list, tcfm_list) { list_for_each_entry(m, &mirred_list, tcfm_list) {
spin_lock_bh(&m->tcf_lock);
if (m->tcfm_dev == dev) { if (m->tcfm_dev == dev) {
dev_put(dev); dev_put(dev);
m->tcfm_dev = NULL; m->tcfm_dev = NULL;
} }
spin_unlock_bh(&m->tcf_lock);
} }
return NOTIFY_DONE; return NOTIFY_DONE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment