Move fdput() to right place in ksys_sync_file_range() to avoid fdput() after failed fdget(). Signed-off-by: Chengguang Xu <cgxu519@xxxxxxxxxxxx> --- 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