[PATCH] fuse: set ff->flock only on success
From: Zhang Tianci
Date: Thu Dec 25 2025 - 06:12:48 EST
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 <liyichao.1@xxxxxxxxxxxxx>
Signed-off-by: Zhang Tianci <zhangtianci.1997@xxxxxxxxxxxxx>
---
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 01bc894e9c2ba..d83ef81e3b9b3 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -2563,8 +2563,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;
--
2.39.5