diff options
author | Miklos Szeredi <mszeredi@redhat.com> | 2021-04-14 10:40:58 +0200 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2021-04-14 10:40:58 +0200 |
commit | 3c9c14338c12fb6f8d3aea7e7a1b7f93ce9e84b0 (patch) | |
tree | f40b31ab18582295c6764b8002ffa1ecac2f068e /fs | |
parent | cuse: prevent clone (diff) | |
download | linux-3c9c14338c12fb6f8d3aea7e7a1b7f93ce9e84b0.tar.xz linux-3c9c14338c12fb6f8d3aea7e7a1b7f93ce9e84b0.zip |
cuse: simplify refcount
Put extra reference early in cuse_channel_open().
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fuse/cuse.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c index a37528b51798..c7d882a9fe33 100644 --- a/fs/fuse/cuse.c +++ b/fs/fuse/cuse.c @@ -511,20 +511,18 @@ static int cuse_channel_open(struct inode *inode, struct file *file) fuse_conn_init(&cc->fc, &cc->fm, file->f_cred->user_ns, &fuse_dev_fiq_ops, NULL); + cc->fc.release = cuse_fc_release; fud = fuse_dev_alloc_install(&cc->fc); - if (!fud) { - kfree(cc); + fuse_conn_put(&cc->fc); + if (!fud) return -ENOMEM; - } INIT_LIST_HEAD(&cc->list); - cc->fc.release = cuse_fc_release; cc->fc.initialized = 1; rc = cuse_send_init(cc); if (rc) { fuse_dev_free(fud); - fuse_conn_put(&cc->fc); return rc; } file->private_data = fud; @@ -561,8 +559,6 @@ static int cuse_channel_release(struct inode *inode, struct file *file) unregister_chrdev_region(cc->cdev->dev, 1); cdev_del(cc->cdev); } - /* Base reference is now owned by "fud" */ - fuse_conn_put(&cc->fc); rc = fuse_dev_release(inode, file); /* puts the base reference */ |