2021-12-28 03:09:32

by Xianting Tian

[permalink] [raw]
Subject: [PATCH] vhost/test: fix memory leak of vhost virtqueues

We need free the vqs in .release(), which are allocated in .open().

Signed-off-by: Xianting Tian <[email protected]>
---
drivers/vhost/test.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
index a09dedc79..05740cba1 100644
--- a/drivers/vhost/test.c
+++ b/drivers/vhost/test.c
@@ -166,6 +166,7 @@ static int vhost_test_release(struct inode *inode, struct file *f)
/* We do an extra flush before freeing memory,
* since jobs can re-queue themselves. */
vhost_test_flush(n);
+ kfree(n->dev.vqs);
kfree(n);
return 0;
}
--
2.17.1



2022-01-04 05:58:54

by Xianting Tian

[permalink] [raw]
Subject: Re: [PATCH] vhost/test: fix memory leak of vhost virtqueues

hi

Could I get your comments for this patch?  it fixed the memleak issue.

在 2021/12/28 上午11:09, Xianting Tian 写道:
> We need free the vqs in .release(), which are allocated in .open().
>
> Signed-off-by: Xianting Tian <[email protected]>
> ---
> drivers/vhost/test.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
> index a09dedc79..05740cba1 100644
> --- a/drivers/vhost/test.c
> +++ b/drivers/vhost/test.c
> @@ -166,6 +166,7 @@ static int vhost_test_release(struct inode *inode, struct file *f)
> /* We do an extra flush before freeing memory,
> * since jobs can re-queue themselves. */
> vhost_test_flush(n);
> + kfree(n->dev.vqs);
> kfree(n);
> return 0;
> }

2022-01-04 06:18:30

by Jason Wang

[permalink] [raw]
Subject: Re: [PATCH] vhost/test: fix memory leak of vhost virtqueues

On Tue, Jan 4, 2022 at 1:59 PM Xianting Tian
<[email protected]> wrote:
>
> hi
>
> Could I get your comments for this patch? it fixed the memleak issue.
>
> 在 2021/12/28 上午11:09, Xianting Tian 写道:
> > We need free the vqs in .release(), which are allocated in .open().
> >
> > Signed-off-by: Xianting Tian <[email protected]>

Acked-by: Jason Wang <[email protected]>

> > ---
> > drivers/vhost/test.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c
> > index a09dedc79..05740cba1 100644
> > --- a/drivers/vhost/test.c
> > +++ b/drivers/vhost/test.c
> > @@ -166,6 +166,7 @@ static int vhost_test_release(struct inode *inode, struct file *f)
> > /* We do an extra flush before freeing memory,
> > * since jobs can re-queue themselves. */
> > vhost_test_flush(n);
> > + kfree(n->dev.vqs);
> > kfree(n);
> > return 0;
> > }
>