# \[PATCH 12/17\] timers: assert static storage for DEFINE\_TIMER()

- From: Yury Norov \<hidden\>
- Date: 2026-09-15 03:14:09 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2026/09/17576920
- Thread: https://ratatoskr.run/linuxppc-dev/2026/09/17576885/t.md

```text
DEFINE_TIMER() marks a timer as statically initialized for debugobjects.
An automatic local timer instead needs timer_setup_on_stack() and the
corresponding on-stack destruction before leaving scope.

Add ASSERT_STATIC_STORAGE() to catch automatic declarations at compile
time. The timer lockdep key is already static; this check enforces the
debugobjects storage contract. Leave __TIMER_INITIALIZER() unchanged.

Assisted-by: OpenAI Codex
Signed-off-by: Yury Norov <redacted>
---
 include/linux/timer.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/linux/timer.h b/include/linux/timer.h
index 62e1cea71125..420509329883 100644
--- a/include/linux/timer.h
+++ b/include/linux/timer.h
@@ -2,6 +2,7 @@
 #ifndef _LINUX_TIMER_H
 #define _LINUX_TIMER_H
 
+#include <linux/compiler.h>
 #include <linux/list.h>
 #include <linux/ktime.h>
 #include <linux/stddef.h>
@@ -62,7 +63,8 @@
 
 #define DEFINE_TIMER(_name, _function)				\
 	struct timer_list _name =				\
-		__TIMER_INITIALIZER(_function, 0)
+		__TIMER_INITIALIZER(_function, 0);		\
+	ASSERT_STATIC_STORAGE(_name)
 
 /*
  * LOCKDEP and DEBUG timer interfaces.
-- 
2.53.0


```
