[PATCH v3 1/2] eventfd: Add scope-based cleanup capability

From: Bence Csokas

Date: Tue Oct 27 2026 - 12:30:13 EST


Allow eventfd_ctx_put() to be used with the RAII-inspired __free() API.

Signed-off-by: Bence Csokas <bence.csokas@xxxxxxx>
---
include/linux/eventfd.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h
index e32bee4345fb..48c40f8c4dfd 100644
--- a/include/linux/eventfd.h
+++ b/include/linux/eventfd.h
@@ -10,6 +10,7 @@
#define _LINUX_EVENTFD_H

#include <linux/wait.h>
+#include <linux/cleanup.h>
#include <linux/err.h>
#include <linux/percpu-defs.h>
#include <linux/percpu.h>
@@ -89,5 +90,7 @@ static inline void eventfd_signal(struct eventfd_ctx *ctx)
eventfd_signal_mask(ctx, 0);
}

+DEFINE_FREE(eventfd, struct eventfd_ctx *, if (!IS_ERR_OR_NULL(_T)) eventfd_ctx_put(_T))
+
#endif /* _LINUX_EVENTFD_H */


--
2.56.0