From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Alexander Viro <viro@zeniv.linux.org.uk>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Christian Brauner <brauner@kernel.org>,
Wentao Guan <guanwentao@uniontech.com>,
Josef Bacik <josef@toxicpanda.com>,
Jeff Layton <jlayton@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Paolo Abeni <pabeni@redhat.com>,
Andrew Morton <akpm@linux-foundation.org>,
Soheil Hassas Yeganeh <soheil@google.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Eric Dumazet <edumazet@google.com>,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [STABLE v5.15.y 1/8] file: add fput() cleanup helper
Date: Tue, 8 Sep 2026 09:50:57 +0100 [thread overview]
Message-ID: <20260908085113.3960814-1-lee@kernel.org> (raw)
From: Christian Brauner <brauner@kernel.org>
[ Upstream commit 257b1c2c78c25643526609dee0c15f1544eb3252 ]
Add a simple helper to put a file reference.
Link: https://lore.kernel.org/r/20240719-work-mount-namespace-v1-4-834113cab0d2@kernel.org
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit ac275934626a85285cca43405e876566daa10533)
Signed-off-by: Lee Jones <lee@kernel.org>
---
include/linux/file.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/include/linux/file.h b/include/linux/file.h
index 6726240b9279..fb8a5d22531e 100644
--- a/include/linux/file.h
+++ b/include/linux/file.h
@@ -11,6 +11,7 @@
#include <linux/posix_types.h>
#include <linux/errno.h>
#include <linux/cleanup.h>
+#include <linux/err.h>
struct file;
@@ -95,6 +96,7 @@ extern void put_unused_fd(unsigned int fd);
DEFINE_CLASS(get_unused_fd, int, if (_T >= 0) put_unused_fd(_T),
get_unused_fd_flags(flags), unsigned flags)
+DEFINE_FREE(fput, struct file *, if (!IS_ERR_OR_NULL(_T)) fput(_T))
extern void fd_install(unsigned int fd, struct file *file);
--
2.55.0.979.g7e5102b832-goog
next reply other threads:[~2026-09-08 8:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 8:50 Lee Jones [this message]
2026-09-08 8:50 ` [STABLE v5.15.y 2/8] eventpoll: use hlist_is_singular_node() in __ep_remove() Lee Jones
2026-09-08 8:50 ` [STABLE v5.15.y 3/8] eventpoll: split __ep_remove() Lee Jones
2026-09-08 8:51 ` [STABLE v5.15.y 4/8] eventpoll: kill __ep_remove() Lee Jones
2026-09-08 22:39 ` Sasha Levin
2026-09-08 8:51 ` [STABLE v5.15.y 5/8] eventpoll: drop vestigial __ prefix from ep_remove_{file,epi}() Lee Jones
2026-09-08 8:51 ` [STABLE v5.15.y 6/8] eventpoll: rename ep_remove_safe() back to ep_remove() Lee Jones
2026-09-08 8:51 ` [STABLE v5.15.y 7/8] eventpoll: move epi_fget() up Lee Jones
2026-09-08 8:51 ` [STABLE v5.15.y 8/8] eventpoll: fix ep_remove struct eventpoll / struct file UAF Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260908085113.3960814-1-lee@kernel.org \
--to=lee@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=dave@stgolabs.net \
--cc=edumazet@google.com \
--cc=gregkh@linuxfoundation.org \
--cc=guanwentao@uniontech.com \
--cc=jlayton@kernel.org \
--cc=josef@toxicpanda.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=peterz@infradead.org \
--cc=soheil@google.com \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®