decnet: proper socket refcounting
Better use sk_reset_timer() / sk_stop_timer() helpers to make sure we dont access already freed/reused memory later. Reported-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Tested-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
fc0b927d9a
commit
8a6e77d520
1 changed files with 5 additions and 12 deletions
|
@ -36,16 +36,13 @@ static void dn_slow_timer(unsigned long arg);
|
||||||
|
|
||||||
void dn_start_slow_timer(struct sock *sk)
|
void dn_start_slow_timer(struct sock *sk)
|
||||||
{
|
{
|
||||||
sk->sk_timer.expires = jiffies + SLOW_INTERVAL;
|
setup_timer(&sk->sk_timer, dn_slow_timer, (unsigned long)sk);
|
||||||
sk->sk_timer.function = dn_slow_timer;
|
sk_reset_timer(sk, &sk->sk_timer, jiffies + SLOW_INTERVAL);
|
||||||
sk->sk_timer.data = (unsigned long)sk;
|
|
||||||
|
|
||||||
add_timer(&sk->sk_timer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dn_stop_slow_timer(struct sock *sk)
|
void dn_stop_slow_timer(struct sock *sk)
|
||||||
{
|
{
|
||||||
del_timer(&sk->sk_timer);
|
sk_stop_timer(sk, &sk->sk_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dn_slow_timer(unsigned long arg)
|
static void dn_slow_timer(unsigned long arg)
|
||||||
|
@ -53,12 +50,10 @@ static void dn_slow_timer(unsigned long arg)
|
||||||
struct sock *sk = (struct sock *)arg;
|
struct sock *sk = (struct sock *)arg;
|
||||||
struct dn_scp *scp = DN_SK(sk);
|
struct dn_scp *scp = DN_SK(sk);
|
||||||
|
|
||||||
sock_hold(sk);
|
|
||||||
bh_lock_sock(sk);
|
bh_lock_sock(sk);
|
||||||
|
|
||||||
if (sock_owned_by_user(sk)) {
|
if (sock_owned_by_user(sk)) {
|
||||||
sk->sk_timer.expires = jiffies + HZ / 10;
|
sk_reset_timer(sk, &sk->sk_timer, jiffies + HZ / 10);
|
||||||
add_timer(&sk->sk_timer);
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,9 +95,7 @@ static void dn_slow_timer(unsigned long arg)
|
||||||
scp->keepalive_fxn(sk);
|
scp->keepalive_fxn(sk);
|
||||||
}
|
}
|
||||||
|
|
||||||
sk->sk_timer.expires = jiffies + SLOW_INTERVAL;
|
sk_reset_timer(sk, &sk->sk_timer, jiffies + SLOW_INTERVAL);
|
||||||
|
|
||||||
add_timer(&sk->sk_timer);
|
|
||||||
out:
|
out:
|
||||||
bh_unlock_sock(sk);
|
bh_unlock_sock(sk);
|
||||||
sock_put(sk);
|
sock_put(sk);
|
||||||
|
|
Loading…
Reference in a new issue