]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fuse: set ff->flock only on success
authorZhang Tianci <zhangtianci.1997@bytedance.com>
Thu, 25 Dec 2025 11:11:56 +0000 (19:11 +0800)
committerMiklos Szeredi <mszeredi@redhat.com>
Mon, 15 Jun 2026 12:06:20 +0000 (14:06 +0200)
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@bytedance.com>
Signed-off-by: Zhang Tianci <zhangtianci.1997@bytedance.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/fuse/file.c

index 8c8d9f6d8f724dba56faf61ac5f334e94403f6b1..9160836664b0ac0e35fa82bf8c2a6415fa7ecb4c 100644 (file)
@@ -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;