diff mbox

9pfs: fix memory leak in v9fs_link

Message ID 57fde276.652f6b0a.4ba6d.b725@mx.google.com
State New
Headers show

Commit Message

Li Qiang Oct. 12, 2016, 7:12 a.m. UTC
From: Li Qiang <liqiang6-s@360.cn>

In v9fs_link dispatch function, it doesn't put the 'oldfidp'
fid object, this will make the 'oldfidp->ref' never reach to 0,
thus leading a memory leak issue. This patch fix this.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
---
 hw/9pfs/9p.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Greg Kurz Oct. 12, 2016, 1:37 p.m. UTC | #1
On Wed, 12 Oct 2016 00:12:48 -0700
Li Qiang <liq3ea@gmail.com> wrote:

> From: Li Qiang <liqiang6-s@360.cn>
> 
> In v9fs_link dispatch function, it doesn't put the 'oldfidp'
> fid object, this will make the 'oldfidp->ref' never reach to 0,
> thus leading a memory leak issue. This patch fix this.
> 
> Signed-off-by: Li Qiang <liqiang6-s@360.cn>
> ---

Good catch!

Reviewed-by: Greg Kurz <groug@kaod.org>

>  hw/9pfs/9p.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index 8b50bfb..29f8b7a 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -2413,6 +2413,7 @@ static void v9fs_link(void *opaque)
>      if (!err) {
>          err = offset;
>      }
> +    put_fid(pdu, oldfidp);
>  out:
>      put_fid(pdu, dfidp);
>  out_nofid:
diff mbox

Patch

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 8b50bfb..29f8b7a 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -2413,6 +2413,7 @@  static void v9fs_link(void *opaque)
     if (!err) {
         err = offset;
     }
+    put_fid(pdu, oldfidp);
 out:
     put_fid(pdu, dfidp);
 out_nofid: