The vStorage open in close_wait branch runs after fuse_file_io_open() has
taken the inode io-mode reference. However when fuse_finish_open() returns
error, its caller tears the file down via fuse_sync_release(), which doesn't
call fuse_file_io_release() (ra->inode is NULL), leaking iocachectr and
triggering WARN_ON(fi->iocachectr != 0) in fuse_evict_inode().

Fix the leak by calling fuse_file_io_release() on the failure path.

https://virtuozzo.atlassian.net/browse/VSTOR-136977

Signed-off-by: Liu Kui <[email protected]>
---
 fs/fuse/file.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 2855986c987d..f77c784b938f 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -353,6 +353,15 @@ int fuse_finish_open(struct inode *inode, struct file 
*file)
 
                if (!err)
                        err = fuse_open_close_wait(inode, file);
+
+               /*
+                * fuse_file_io_open() has already taken the inode io-mode 
reference
+                * (fi->iocachectr). On failure the caller tears the file down 
via
+                * fuse_sync_release(), which does not call 
fuse_file_io_release()
+                * because ra->inode is NULL for synchronous release.
+                */
+               if (err)
+                       fuse_file_io_release(ff, inode);
        }
 
        return err;
-- 
2.50.1 (Apple Git-155)

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to