[2/2] fs/fuse kio: fix inode leak in pcs_fuse_submit()

Submitted by Pavel Butsykin on May 31, 2019, 1:44 p.m.

Details

Message ID 20190531134455.11239-2-pbutsykin@virtuozzo.com
State New
Series "Series without cover letter"
Headers show

Commit Message

Pavel Butsykin May 31, 2019, 1:44 p.m.
In the case when already prepared request will be rejected due to
FUSE_S_FAIL_IMMEDIATELY state in pcs_fuse_submit(), we will have inode
leak that is referenced in pcs_fuse_prep_rw().

Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index d97854ade4e8..0d8cb3a751e2 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -981,6 +981,9 @@  static int pcs_fuse_prep_rw(struct pcs_fuse_req *r, struct fuse_file *ff)
 	default:
 		BUG();
 	}
+
+	if (!kqueue_insert(di, ff, req))
+		return -EIO;
 	inode_dio_begin(req->io_inode);
 	return 0;
 fail:
@@ -1087,10 +1090,6 @@  error:
 	return;
 
 submit:
-	if (!kqueue_insert(di, ff, req)) {
-		req->out.h.error = -EIO;
-		goto error;
-	}
 	ireq_process(ireq);
 }