fuse: fix memleak in cuse_channel_open
diff mbox series

Message ID 1565769549-127890-1-git-send-email-zhengbin13@huawei.com
State New
Headers show
Series
  • fuse: fix memleak in cuse_channel_open
Related show

Commit Message

zhengbin Aug. 14, 2019, 7:59 a.m. UTC
If cuse_send_init fails, need to fuse_conn_put cc->fc.

cuse_channel_open->fuse_conn_init->refcount_set(&fc->count, 1)
                 ->fuse_dev_alloc->fuse_conn_get
                 ->fuse_dev_free->fuse_conn_put

Fixes: cc080e9e9be1 ("fuse: introduce per-instance fuse_dev structure")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: zhengbin <zhengbin13@huawei.com>
---
 fs/fuse/cuse.c | 1 +
 1 file changed, 1 insertion(+)

--
2.7.4

Comments

zhengbin Sept. 4, 2019, 8:46 a.m. UTC | #1
ping

On 2019/8/14 15:59, zhengbin wrote:
> If cuse_send_init fails, need to fuse_conn_put cc->fc.
>
> cuse_channel_open->fuse_conn_init->refcount_set(&fc->count, 1)
>                  ->fuse_dev_alloc->fuse_conn_get
>                  ->fuse_dev_free->fuse_conn_put
>
> Fixes: cc080e9e9be1 ("fuse: introduce per-instance fuse_dev structure")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  fs/fuse/cuse.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
> index bab7a0d..f3b7208 100644
> --- a/fs/fuse/cuse.c
> +++ b/fs/fuse/cuse.c
> @@ -519,6 +519,7 @@ static int cuse_channel_open(struct inode *inode, struct file *file)
>  	rc = cuse_send_init(cc);
>  	if (rc) {
>  		fuse_dev_free(fud);
> +		fuse_conn_put(&cc->fc);
>  		return rc;
>  	}
>  	file->private_data = fud;
> --
> 2.7.4
>
>
> .
>
zhengbin Sept. 23, 2019, 6:26 a.m. UTC | #2
ping

On 2019/8/14 15:59, zhengbin wrote:
> If cuse_send_init fails, need to fuse_conn_put cc->fc.
>
> cuse_channel_open->fuse_conn_init->refcount_set(&fc->count, 1)
>                  ->fuse_dev_alloc->fuse_conn_get
>                  ->fuse_dev_free->fuse_conn_put
>
> Fixes: cc080e9e9be1 ("fuse: introduce per-instance fuse_dev structure")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>
> ---
>  fs/fuse/cuse.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
> index bab7a0d..f3b7208 100644
> --- a/fs/fuse/cuse.c
> +++ b/fs/fuse/cuse.c
> @@ -519,6 +519,7 @@ static int cuse_channel_open(struct inode *inode, struct file *file)
>  	rc = cuse_send_init(cc);
>  	if (rc) {
>  		fuse_dev_free(fud);
> +		fuse_conn_put(&cc->fc);
>  		return rc;
>  	}
>  	file->private_data = fud;
> --
> 2.7.4
>
>
> .
>
Miklos Szeredi Sept. 23, 2019, 7:04 a.m. UTC | #3
On Wed, Aug 14, 2019 at 9:52 AM zhengbin <zhengbin13@huawei.com> wrote:
>
> If cuse_send_init fails, need to fuse_conn_put cc->fc.
>
> cuse_channel_open->fuse_conn_init->refcount_set(&fc->count, 1)
>                  ->fuse_dev_alloc->fuse_conn_get
>                  ->fuse_dev_free->fuse_conn_put
>
> Fixes: cc080e9e9be1 ("fuse: introduce per-instance fuse_dev structure")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: zhengbin <zhengbin13@huawei.com>

Thanks, applied.

Miklos

Patch
diff mbox series

diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
index bab7a0d..f3b7208 100644
--- a/fs/fuse/cuse.c
+++ b/fs/fuse/cuse.c
@@ -519,6 +519,7 @@  static int cuse_channel_open(struct inode *inode, struct file *file)
 	rc = cuse_send_init(cc);
 	if (rc) {
 		fuse_dev_free(fud);
+		fuse_conn_put(&cc->fc);
 		return rc;
 	}
 	file->private_data = fud;