All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfs: move fdput() to right place in ksys_sync_file_range()
@ 2022-05-11 15:45 Chengguang Xu
  2022-05-11 15:51 ` Matthew Wilcox
  0 siblings, 1 reply; 13+ messages in thread
From: Chengguang Xu @ 2022-05-11 15:45 UTC (permalink / raw)
  To: viro; +Cc: linux-fsdevel, Chengguang Xu

Move fdput() to right place in ksys_sync_file_range() to
avoid fdput() after failed fdget().

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
---
 fs/sync.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/sync.c b/fs/sync.c
index c7690016453e..b217d908bee8 100644
--- a/fs/sync.c
+++ b/fs/sync.c
@@ -360,10 +360,10 @@ int ksys_sync_file_range(int fd, loff_t offset, loff_t nbytes,
 
 	ret = -EBADF;
 	f = fdget(fd);
-	if (f.file)
+	if (f.file) {
 		ret = sync_file_range(f.file, offset, nbytes, flags);
-
-	fdput(f);
+		fdput(f);
+	}
 	return ret;
 }
 
-- 
2.35.1



^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-05-16  8:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-11 15:45 [PATCH] vfs: move fdput() to right place in ksys_sync_file_range() Chengguang Xu
2022-05-11 15:51 ` Matthew Wilcox
2022-05-11 19:01   ` Eric Biggers
2022-05-11 21:43     ` Al Viro
2022-05-12  0:28       ` Al Viro
2022-05-12  0:42         ` Jens Axboe
2022-05-12  2:03       ` Alexei Starovoitov
2022-05-12 12:48         ` Brian Vazquez
2022-05-15  3:30       ` [BUG] double fget() in vhost/net (was Re: [PATCH] vfs: move fdput() to right place in ksys_sync_file_range()) Al Viro
2022-05-15 16:14         ` Michael S. Tsirkin
2022-05-16  4:17         ` Jason Wang
2022-05-16  7:54           ` Michael S. Tsirkin
2022-05-16  8:42             ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.