Commit 2d9073922bc73f8cb847ce354f0896205f6981a1

Authored by Stephen Hemminger
Committed by David S. Miller
1 parent f3a0592b37

[ATM]: Clip timer race.

By inspection, the clip idle timer code is racy on SMP.
Here is a safe version of timer management.
Untested, I don't have ATM hardware.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 1 changed file with 5 additions and 11 deletions Side-by-side Diff

... ... @@ -54,9 +54,7 @@
54 54 static struct atm_vcc *atmarpd;
55 55 static struct neigh_table clip_tbl;
56 56 static struct timer_list idle_timer;
57   -static int start_timer = 1;
58 57  
59   -
60 58 static int to_atmarpd(enum atmarp_ctrl_type type,int itf,unsigned long ip)
61 59 {
62 60 struct sock *sk;
... ... @@ -725,13 +723,8 @@
725 723 return -EADDRINUSE;
726 724 }
727 725  
728   - if (start_timer) {
729   - start_timer = 0;
730   - init_timer(&idle_timer);
731   - idle_timer.expires = jiffies+CLIP_CHECK_INTERVAL*HZ;
732   - idle_timer.function = idle_timer_check;
733   - add_timer(&idle_timer);
734   - }
  726 + mod_timer(&idle_timer, jiffies+CLIP_CHECK_INTERVAL*HZ);
  727 +
735 728 atmarpd = vcc;
736 729 set_bit(ATM_VF_META,&vcc->flags);
737 730 set_bit(ATM_VF_READY,&vcc->flags);
... ... @@ -1002,6 +995,8 @@
1002 995 register_netdevice_notifier(&clip_dev_notifier);
1003 996 register_inetaddr_notifier(&clip_inet_notifier);
1004 997  
  998 + setup_timer(&idle_timer, idle_timer_check, 0);
  999 +
1005 1000 #ifdef CONFIG_PROC_FS
1006 1001 {
1007 1002 struct proc_dir_entry *p;
... ... @@ -1029,8 +1024,7 @@
1029 1024 /* First, stop the idle timer, so it stops banging
1030 1025 * on the table.
1031 1026 */
1032   - if (start_timer == 0)
1033   - del_timer(&idle_timer);
  1027 + del_timer_sync(&idle_timer);
1034 1028  
1035 1029 /* Next, purge the table, so that the device
1036 1030 * unregister loop below does not hang due to