[PATCH 01/20] headers: Add timer_shutdown_sync()
Yi Cong <[email protected]> Wed, 24 Jun 2026 15:38:25 +0800
| Newsgroups | org.kernel.vger.backports |
|---|---|
| Message-ID | <[email protected]> |
From: Yi Cong <[email protected]> timer_shutdown_sync() was introduced in v6.2. On older kernels it needs to delete the timer and set its function callback to NULL to emulate the shutdown semantics (prevent the timer from being rearmed). Signed-off-by: Yi Cong <[email protected]> --- backport/backport-include/linux/timer.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/backport/backport-include/linux/timer.h b/backport/backport-include/linux/timer.h index 14467fb6..36e15340 100644 --- a/backport/backport-include/linux/timer.h +++ b/backport/backport-include/linux/timer.h @@ -79,4 +79,18 @@ static inline int timer_delete_sync(struct timer_list *timer) } #endif /* < 6.1.84 */ +#if LINUX_VERSION_IS_LESS(6,2,0) +static inline int timer_shutdown_sync(struct timer_list *timer) +{ + int ret = del_timer_sync(timer); + /* + * Emulate shutdown semantics: mark as dead to prevent accidental reuse. + * Safe to do after del_timer_sync() because timer is no longer + * referenced by the timer subsystem. + */ + timer->function = NULL; + return ret; +} +#endif + #endif /* _BACKPORT_TIMER_H */ -- 2.43.0