qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 6/9] 9pfs: fix memory leak


From: Michael Tokarev
Subject: Re: [Qemu-devel] [PATCH 6/9] 9pfs: fix memory leak
Date: Sat, 28 Feb 2015 12:46:22 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.4.0

27.02.2015 10:50, address@hidden wrote:
> From: Gonglei <address@hidden>
> 
> Signed-off-by: Gonglei <address@hidden>
> ---
>  hw/9pfs/virtio-9p-local.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c
> index a183eee..bcad4e0 100644
> --- a/hw/9pfs/virtio-9p-local.c
> +++ b/hw/9pfs/virtio-9p-local.c
> @@ -500,7 +500,6 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath 
> *dir_path,
>          buffer = rpath(fs_ctx, path);
>          err = mknod(buffer, SM_LOCAL_MODE_BITS|S_IFREG, 0);
>          if (err == -1) {
> -            g_free(buffer);
>              goto out;
>          }
>          err = local_set_xattr(buffer, credp);
> @@ -513,7 +512,6 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath 
> *dir_path,
>          buffer = rpath(fs_ctx, path);
>          err = mknod(buffer, SM_LOCAL_MODE_BITS|S_IFREG, 0);
>          if (err == -1) {
> -            g_free(buffer);
>              goto out;
>          }
>          err = local_set_mapped_file_attr(fs_ctx, path, credp);
> @@ -526,7 +524,6 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath 
> *dir_path,
>          buffer = rpath(fs_ctx, path);
>          err = mknod(buffer, credp->fc_mode, credp->fc_rdev);
>          if (err == -1) {
> -            g_free(buffer);
>              goto out;
>          }
...

I wonder if we should change this code to drop repeated code blocks which 
changes
only slightly by mknod parameters...

>          err = local_post_create_passthrough(fs_ctx, path, credp);
> @@ -540,8 +537,8 @@ static int local_mknod(FsContext *fs_ctx, V9fsPath 
> *dir_path,
>  err_end:
>      remove(buffer);
>      errno = serrno;
> -    g_free(buffer);
>  out:
> +    g_free(buffer);
>      v9fs_string_free(&fullname);
>      return err;
>  }

..and this goto jumping (here and in a few other places) is q bit disgusting 
too... ;)

But this is the original code, the patch is still correct.

Thanks,

/mjt



reply via email to

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