From 71947173cef279be5eed209ec28f8c11f9d73159 Mon Sep 17 00:00:00 2001 From: Zhang Tianci Date: Thu, 25 Dec 2025 19:11:56 +0800 Subject: [PATCH] fuse: set ff->flock only on success If FUSE_SETLK fails (e.g., due to EWOULDBLOCK), we shall not set FUSE_RELEASE_FLOCK_UNLOCK in fuse_file_release(). Reported-by: Li Yichao Signed-off-by: Zhang Tianci Signed-off-by: Miklos Szeredi --- fs/fuse/file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 8c8d9f6d8f72..9160836664b0 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -2569,8 +2569,9 @@ static int fuse_file_flock(struct file *file, int cmd, struct file_lock *fl) struct fuse_file *ff = file->private_data; /* emulate flock with POSIX locks */ - ff->flock = true; err = fuse_setlk(file, fl, 1); + if (!err) + ff->flock = true; } return err;