diff options
author | Jarek Poplawski <jarkao2@gmail.com> | 2008-02-12 00:36:39 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-12 20:53:33 -0500 |
commit | 21fab4a86a411c18c6b4d663ae710ca1f6206b3c (patch) | |
tree | ae10e8f7571a04cb16147403bb8a11e8e55d8d10 /net | |
parent | 4de211f1a279275c6c67d6e9b6b25513e46b0bb9 (diff) |
[AX25] ax25_timer: use mod_timer instead of add_timer
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/ax25/af_ax25.c | 6 | ||||
-rw-r--r-- | net/ax25/ax25_timer.c | 60 |
2 files changed, 22 insertions, 44 deletions
diff --git a/net/ax25/af_ax25.c b/net/ax25/af_ax25.c index 5a4337a29094..48bfcc741f25 100644 --- a/net/ax25/af_ax25.c +++ b/net/ax25/af_ax25.c | |||
@@ -510,11 +510,7 @@ ax25_cb *ax25_create_cb(void) | |||
510 | skb_queue_head_init(&ax25->ack_queue); | 510 | skb_queue_head_init(&ax25->ack_queue); |
511 | skb_queue_head_init(&ax25->reseq_queue); | 511 | skb_queue_head_init(&ax25->reseq_queue); |
512 | 512 | ||
513 | init_timer(&ax25->timer); | 513 | ax25_setup_timers(ax25); |
514 | init_timer(&ax25->t1timer); | ||
515 | init_timer(&ax25->t2timer); | ||
516 | init_timer(&ax25->t3timer); | ||
517 | init_timer(&ax25->idletimer); | ||
518 | 514 | ||
519 | ax25_fillin_cb(ax25, NULL); | 515 | ax25_fillin_cb(ax25, NULL); |
520 | 516 | ||
diff --git a/net/ax25/ax25_timer.c b/net/ax25/ax25_timer.c index 72594867fab6..db29ea71e80a 100644 --- a/net/ax25/ax25_timer.c +++ b/net/ax25/ax25_timer.c | |||
@@ -40,63 +40,45 @@ static void ax25_t2timer_expiry(unsigned long); | |||
40 | static void ax25_t3timer_expiry(unsigned long); | 40 | static void ax25_t3timer_expiry(unsigned long); |
41 | static void ax25_idletimer_expiry(unsigned long); | 41 | static void ax25_idletimer_expiry(unsigned long); |
42 | 42 | ||
43 | void ax25_start_heartbeat(ax25_cb *ax25) | 43 | void ax25_setup_timers(ax25_cb *ax25) |
44 | { | 44 | { |
45 | del_timer(&ax25->timer); | 45 | setup_timer(&ax25->timer, ax25_heartbeat_expiry, (unsigned long)ax25); |
46 | 46 | setup_timer(&ax25->t1timer, ax25_t1timer_expiry, (unsigned long)ax25); | |
47 | ax25->timer.data = (unsigned long)ax25; | 47 | setup_timer(&ax25->t2timer, ax25_t2timer_expiry, (unsigned long)ax25); |
48 | ax25->timer.function = &ax25_heartbeat_expiry; | 48 | setup_timer(&ax25->t3timer, ax25_t3timer_expiry, (unsigned long)ax25); |
49 | ax25->timer.expires = jiffies + 5 * HZ; | 49 | setup_timer(&ax25->idletimer, ax25_idletimer_expiry, |
50 | (unsigned long)ax25); | ||
51 | } | ||
50 | 52 | ||
51 | add_timer(&ax25->timer); | 53 | void ax25_start_heartbeat(ax25_cb *ax25) |
54 | { | ||
55 | mod_timer(&ax25->timer, jiffies + 5 * HZ); | ||
52 | } | 56 | } |
53 | 57 | ||
54 | void ax25_start_t1timer(ax25_cb *ax25) | 58 | void ax25_start_t1timer(ax25_cb *ax25) |
55 | { | 59 | { |
56 | del_timer(&ax25->t1timer); | 60 | mod_timer(&ax25->t1timer, jiffies + ax25->t1); |
57 | |||
58 | ax25->t1timer.data = (unsigned long)ax25; | ||
59 | ax25->t1timer.function = &ax25_t1timer_expiry; | ||
60 | ax25->t1timer.expires = jiffies + ax25->t1; | ||
61 | |||
62 | add_timer(&ax25->t1timer); | ||
63 | } | 61 | } |
64 | 62 | ||
65 | void ax25_start_t2timer(ax25_cb *ax25) | 63 | void ax25_start_t2timer(ax25_cb *ax25) |
66 | { | 64 | { |
67 | del_timer(&ax25->t2timer); | 65 | mod_timer(&ax25->t2timer, jiffies + ax25->t2); |
68 | |||
69 | ax25->t2timer.data = (unsigned long)ax25; | ||
70 | ax25->t2timer.function = &ax25_t2timer_expiry; | ||
71 | ax25->t2timer.expires = jiffies + ax25->t2; | ||
72 | |||
73 | add_timer(&ax25->t2timer); | ||
74 | } | 66 | } |
75 | 67 | ||
76 | void ax25_start_t3timer(ax25_cb *ax25) | 68 | void ax25_start_t3timer(ax25_cb *ax25) |
77 | { | 69 | { |
78 | del_timer(&ax25->t3timer); | 70 | if (ax25->t3 > 0) |
79 | 71 | mod_timer(&ax25->t3timer, jiffies + ax25->t3); | |
80 | if (ax25->t3 > 0) { | 72 | else |
81 | ax25->t3timer.data = (unsigned long)ax25; | 73 | del_timer(&ax25->t3timer); |
82 | ax25->t3timer.function = &ax25_t3timer_expiry; | ||
83 | ax25->t3timer.expires = jiffies + ax25->t3; | ||
84 | |||
85 | add_timer(&ax25->t3timer); | ||
86 | } | ||
87 | } | 74 | } |
88 | 75 | ||
89 | void ax25_start_idletimer(ax25_cb *ax25) | 76 | void ax25_start_idletimer(ax25_cb *ax25) |
90 | { | 77 | { |
91 | del_timer(&ax25->idletimer); | 78 | if (ax25->idle > 0) |
92 | 79 | mod_timer(&ax25->idletimer, jiffies + ax25->idle); | |
93 | if (ax25->idle > 0) { | 80 | else |
94 | ax25->idletimer.data = (unsigned long)ax25; | 81 | del_timer(&ax25->idletimer); |
95 | ax25->idletimer.function = &ax25_idletimer_expiry; | ||
96 | ax25->idletimer.expires = jiffies + ax25->idle; | ||
97 | |||
98 | add_timer(&ax25->idletimer); | ||
99 | } | ||
100 | } | 82 | } |
101 | 83 | ||
102 | void ax25_stop_heartbeat(ax25_cb *ax25) | 84 | void ax25_stop_heartbeat(ax25_cb *ax25) |