diff options
author | Christian Brauner <brauner@kernel.org> | 2024-07-19 13:41:51 +0200 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2024-08-09 12:44:50 +0200 |
commit | 257b1c2c78c25643526609dee0c15f1544eb3252 (patch) | |
tree | 994a1f14dbcbd956374cfc04a4aaf1d5ddda447e /include/linux/file.h | |
parent | 5fcf329676cf9d132842d9871f83a091c32f3bfc (diff) |
file: add fput() cleanup helper
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>
Diffstat (limited to 'include/linux/file.h')
-rw-r--r-- | include/linux/file.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/include/linux/file.h b/include/linux/file.h index 237931f20739..d1e768b06069 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; @@ -96,6 +97,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)) /* * take_fd() will take care to set @fd to -EBADF ensuring that |