Skip to content

Commit 6334665

Browse files
congwangdavem330
authored andcommitted
netrom: switch to sock timer API
sk_reset_timer() and sk_stop_timer() properly handle sock refcnt for timer function. Switching to them could fix a refcounting bug reported by syzbot. Reported-and-tested-by: [email protected] Cc: Ralf Baechle <[email protected]> Cc: [email protected] Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c303a9b commit 6334665

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

net/netrom/nr_timer.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,59 +52,59 @@ void nr_start_t1timer(struct sock *sk)
5252
{
5353
struct nr_sock *nr = nr_sk(sk);
5454

55-
mod_timer(&nr->t1timer, jiffies + nr->t1);
55+
sk_reset_timer(sk, &nr->t1timer, jiffies + nr->t1);
5656
}
5757

5858
void nr_start_t2timer(struct sock *sk)
5959
{
6060
struct nr_sock *nr = nr_sk(sk);
6161

62-
mod_timer(&nr->t2timer, jiffies + nr->t2);
62+
sk_reset_timer(sk, &nr->t2timer, jiffies + nr->t2);
6363
}
6464

6565
void nr_start_t4timer(struct sock *sk)
6666
{
6767
struct nr_sock *nr = nr_sk(sk);
6868

69-
mod_timer(&nr->t4timer, jiffies + nr->t4);
69+
sk_reset_timer(sk, &nr->t4timer, jiffies + nr->t4);
7070
}
7171

7272
void nr_start_idletimer(struct sock *sk)
7373
{
7474
struct nr_sock *nr = nr_sk(sk);
7575

7676
if (nr->idle > 0)
77-
mod_timer(&nr->idletimer, jiffies + nr->idle);
77+
sk_reset_timer(sk, &nr->idletimer, jiffies + nr->idle);
7878
}
7979

8080
void nr_start_heartbeat(struct sock *sk)
8181
{
82-
mod_timer(&sk->sk_timer, jiffies + 5 * HZ);
82+
sk_reset_timer(sk, &sk->sk_timer, jiffies + 5 * HZ);
8383
}
8484

8585
void nr_stop_t1timer(struct sock *sk)
8686
{
87-
del_timer(&nr_sk(sk)->t1timer);
87+
sk_stop_timer(sk, &nr_sk(sk)->t1timer);
8888
}
8989

9090
void nr_stop_t2timer(struct sock *sk)
9191
{
92-
del_timer(&nr_sk(sk)->t2timer);
92+
sk_stop_timer(sk, &nr_sk(sk)->t2timer);
9393
}
9494

9595
void nr_stop_t4timer(struct sock *sk)
9696
{
97-
del_timer(&nr_sk(sk)->t4timer);
97+
sk_stop_timer(sk, &nr_sk(sk)->t4timer);
9898
}
9999

100100
void nr_stop_idletimer(struct sock *sk)
101101
{
102-
del_timer(&nr_sk(sk)->idletimer);
102+
sk_stop_timer(sk, &nr_sk(sk)->idletimer);
103103
}
104104

105105
void nr_stop_heartbeat(struct sock *sk)
106106
{
107-
del_timer(&sk->sk_timer);
107+
sk_stop_timer(sk, &sk->sk_timer);
108108
}
109109

110110
int nr_t1timer_running(struct sock *sk)

0 commit comments

Comments
 (0)