[AX25] ax25_timer: use mod_timer instead of add_timer
authorJarek Poplawski <jarkao2@gmail.com>
Tue, 12 Feb 2008 05:36:39 +0000 (21:36 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 Feb 2008 01:53:33 +0000 (17:53 -0800)
According to one of Jann's OOPS reports it looks like
BUG_ON(timer_pending(timer)) triggers during add_timer()
in ax25_start_t1timer(). This patch changes current use
of: init_timer(), add_timer() and del_timer() to
setup_timer() with mod_timer(), which should be safer
anyway.

Reported-by: Jann Traschewski <jann@gmx.de>
Signed-off-by: Jarek Poplawski <jarkao2@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ax25.h
net/ax25/af_ax25.c
net/ax25/ax25_timer.c

index 32a57e1dee3a4f526cc43491b909948b55d0c6d1..3f0236f1d23e93512a9b38baeafec5322ce3197b 100644 (file)
@@ -416,6 +416,7 @@ extern void ax25_calculate_rtt(ax25_cb *);
 extern void ax25_disconnect(ax25_cb *, int);
 
 /* ax25_timer.c */
+extern void ax25_setup_timers(ax25_cb *);
 extern void ax25_start_heartbeat(ax25_cb *);
 extern void ax25_start_t1timer(ax25_cb *);
 extern void ax25_start_t2timer(ax25_cb *);
index 5a4337a29094e37e6626aa11f487afcc3b3aece7..48bfcc741f2595db4f8d4f674e43f6a65751f608 100644 (file)
@@ -510,11 +510,7 @@ ax25_cb *ax25_create_cb(void)
        skb_queue_head_init(&ax25->ack_queue);
        skb_queue_head_init(&ax25->reseq_queue);
 
-       init_timer(&ax25->timer);
-       init_timer(&ax25->t1timer);
-       init_timer(&ax25->t2timer);
-       init_timer(&ax25->t3timer);
-       init_timer(&ax25->idletimer);
+       ax25_setup_timers(ax25);
 
        ax25_fillin_cb(ax25, NULL);
 
index 72594867fab6005978e9df3c2753f6558410acb2..db29ea71e80a599cd667a8d7d0730531f0a90ea3 100644 (file)
@@ -40,63 +40,45 @@ static void ax25_t2timer_expiry(unsigned long);
 static void ax25_t3timer_expiry(unsigned long);
 static void ax25_idletimer_expiry(unsigned long);
 
-void ax25_start_heartbeat(ax25_cb *ax25)
+void ax25_setup_timers(ax25_cb *ax25)
 {
-       del_timer(&ax25->timer);
-
-       ax25->timer.data     = (unsigned long)ax25;
-       ax25->timer.function = &ax25_heartbeat_expiry;
-       ax25->timer.expires  = jiffies + 5 * HZ;
+       setup_timer(&ax25->timer, ax25_heartbeat_expiry, (unsigned long)ax25);
+       setup_timer(&ax25->t1timer, ax25_t1timer_expiry, (unsigned long)ax25);
+       setup_timer(&ax25->t2timer, ax25_t2timer_expiry, (unsigned long)ax25);
+       setup_timer(&ax25->t3timer, ax25_t3timer_expiry, (unsigned long)ax25);
+       setup_timer(&ax25->idletimer, ax25_idletimer_expiry,
+                   (unsigned long)ax25);
+}
 
-       add_timer(&ax25->timer);
+void ax25_start_heartbeat(ax25_cb *ax25)
+{
+       mod_timer(&ax25->timer, jiffies + 5 * HZ);
 }
 
 void ax25_start_t1timer(ax25_cb *ax25)
 {
-       del_timer(&ax25->t1timer);
-
-       ax25->t1timer.data     = (unsigned long)ax25;
-       ax25->t1timer.function = &ax25_t1timer_expiry;
-       ax25->t1timer.expires  = jiffies + ax25->t1;
-
-       add_timer(&ax25->t1timer);
+       mod_timer(&ax25->t1timer, jiffies + ax25->t1);
 }
 
 void ax25_start_t2timer(ax25_cb *ax25)
 {
-       del_timer(&ax25->t2timer);
-
-       ax25->t2timer.data     = (unsigned long)ax25;
-       ax25->t2timer.function = &ax25_t2timer_expiry;
-       ax25->t2timer.expires  = jiffies + ax25->t2;
-
-       add_timer(&ax25->t2timer);
+       mod_timer(&ax25->t2timer, jiffies + ax25->t2);
 }
 
 void ax25_start_t3timer(ax25_cb *ax25)
 {
-       del_timer(&ax25->t3timer);
-
-       if (ax25->t3 > 0) {
-               ax25->t3timer.data     = (unsigned long)ax25;
-               ax25->t3timer.function = &ax25_t3timer_expiry;
-               ax25->t3timer.expires  = jiffies + ax25->t3;
-
-               add_timer(&ax25->t3timer);
-       }
+       if (ax25->t3 > 0)
+               mod_timer(&ax25->t3timer, jiffies + ax25->t3);
+       else
+               del_timer(&ax25->t3timer);
 }
 
 void ax25_start_idletimer(ax25_cb *ax25)
 {
-       del_timer(&ax25->idletimer);
-
-       if (ax25->idle > 0) {
-               ax25->idletimer.data     = (unsigned long)ax25;
-               ax25->idletimer.function = &ax25_idletimer_expiry;
-               ax25->idletimer.expires  = jiffies + ax25->idle;
-
-               add_timer(&ax25->idletimer);
-       }
+       if (ax25->idle > 0)
+               mod_timer(&ax25->idletimer, jiffies + ax25->idle);
+       else
+               del_timer(&ax25->idletimer);
 }
 
 void ax25_stop_heartbeat(ax25_cb *ax25)