[PATCH 1/4] timens: Add a __free() wrapper for put_time_ns()
From: Thomas Weißschuh
Date: Mon Mar 30 2026 - 03:14:45 EST
The wrapper will be used to simplify cleanups of 'struct time_namespace'.
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@xxxxxxxxxxxxx>
---
include/linux/time_namespace.h | 3 +++
1 file changed, 3 insertions(+)
diff --git a/include/linux/time_namespace.h b/include/linux/time_namespace.h
index c1de21a27c34..58bd9728df58 100644
--- a/include/linux/time_namespace.h
+++ b/include/linux/time_namespace.h
@@ -8,6 +8,7 @@
#include <linux/ns_common.h>
#include <linux/err.h>
#include <linux/time64.h>
+#include <linux/cleanup.h>
struct user_namespace;
extern struct user_namespace init_user_ns;
@@ -171,4 +172,6 @@ static inline struct page *find_timens_vvar_page(struct vm_area_struct *vma)
}
#endif /* CONFIG_TIME_NS_VDSO */
+DEFINE_FREE(time_ns, struct time_namespace *, if (_T) put_time_ns(_T))
+
#endif /* _LINUX_TIMENS_H */
--
2.53.0