qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] 9pfs: free the private data memory in device un


From: Greg Kurz
Subject: Re: [Qemu-devel] [PATCH] 9pfs: free the private data memory in device unrealize
Date: Sat, 12 Nov 2016 15:08:36 +0100

Hi Li,

On Sat, 12 Nov 2016 00:13:56 -0800
Li Qiang <address@hidden> wrote:

> From: Li Qiang <address@hidden>
> 
> When the 9pfs use 'handle'/'proxy' as the backend driver it
> will allocate a private data memory. But this memory is not freed in
> the unrealize function thus leading a memory leak issue. This patch
> avoid this.
> 
> Signed-off-by: Li Qiang <address@hidden>
> ---
>  hw/9pfs/9p.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
> index aea7e9d..6524b13 100644
> --- a/hw/9pfs/9p.c
> +++ b/hw/9pfs/9p.c
> @@ -3532,6 +3532,7 @@ void v9fs_device_unrealize_common(V9fsState *s, Error 
> **errp)
>  {
>      g_free(s->ctx.fs_root);
>      g_free(s->tag);
> +    g_free(s->ctx.private);

This is wrong: we cannot do any assumptions on the private data in the core
code. It can only be used in the backend code. You need to add a .cleanup
operation to the FileOperations structure and implement it in the handle and
proxy backends.

Also, it appears that there's more to be done than just freeing the private
data itself:
- handle needs to close mountfd
- proxy needs to close sockfd and free some allocated iov_base

Cheers.

--
Greg

>  }
>  
>  typedef struct VirtfsCoResetData {

        



reply via email to

[Prev in Thread] Current Thread [Next in Thread]