diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-26 02:09:02 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-10-27 14:20:00 +0200 |
commit | f33fec86c011033103c0ab572ffe8e6e36d9ed24 (patch) | |
tree | a0d26cc893c94b16a82b25c24c926aa79fff035c /src/device.c | |
parent | 4ddf81d009853bf094ef14c97939407714f587be (diff) |
timers: it is always reasonable to remove a timer
If struct timer_list has not been setup, it is zeroed, in which case
timer_pending is false, so calling del_timer is safe. Calling del_timer
is also safe on a timer that has already been del_timer'd. And calling
del_timer is safe after a peer is dead, since the whole point of it
being dead is that no more timers are created and all contexts
eventually stop. Finally del_timer uses a lock, which means it's safe to
call it concurrently.
Therefore, we do not need any guards around calls to del_timer. While
we're at it, we can get rid of the old lingering timers_enabled boolean
which wasn't doing anything anyway anymore.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/device.c')
-rw-r--r-- | src/device.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/device.c b/src/device.c index f47ed0f..010fb28 100644 --- a/src/device.c +++ b/src/device.c @@ -80,10 +80,9 @@ static int wg_pm_notification(struct notifier_block *nb, unsigned long action, list_for_each_entry(wg, &device_list, device_list) { mutex_lock(&wg->device_update_lock); list_for_each_entry(peer, &wg->peer_list, peer_list) { + del_timer(&peer->timer_zero_key_material); wg_noise_handshake_clear(&peer->handshake); wg_noise_keypairs_clear(&peer->keypairs); - if (peer->timers_enabled) - del_timer(&peer->timer_zero_key_material); } mutex_unlock(&wg->device_update_lock); } |