Skip to content

Commit 257b1c2

Browse files
committed
file: add fput() cleanup helper
Add a simple helper to put a file reference. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Josef Bacik <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent 5fcf329 commit 257b1c2

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/linux/file.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/posix_types.h>
1212
#include <linux/errno.h>
1313
#include <linux/cleanup.h>
14+
#include <linux/err.h>
1415

1516
struct file;
1617

@@ -96,6 +97,7 @@ extern void put_unused_fd(unsigned int fd);
9697

9798
DEFINE_CLASS(get_unused_fd, int, if (_T >= 0) put_unused_fd(_T),
9899
get_unused_fd_flags(flags), unsigned flags)
100+
DEFINE_FREE(fput, struct file *, if (!IS_ERR_OR_NULL(_T)) fput(_T))
99101

100102
/*
101103
* take_fd() will take care to set @fd to -EBADF ensuring that

0 commit comments

Comments
 (0)