[Qemu-devel] [PATCH] 9pfs: xattr: fix memory leak in v9fs_list_xattr

Li Qiang posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1491562132-69066-1-git-send-email-liqiang6-s@360.cn
Test checkpatch passed
Test docker passed
Test s390x passed
hw/9pfs/9p-xattr.c | 1 +
1 file changed, 1 insertion(+)
[Qemu-devel] [PATCH] 9pfs: xattr: fix memory leak in v9fs_list_xattr
Posted by Li Qiang 7 years ago
Free 'orig_value' in error path.

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

diff --git a/hw/9pfs/9p-xattr.c b/hw/9pfs/9p-xattr.c
index eec160b..d05c1a1 100644
--- a/hw/9pfs/9p-xattr.c
+++ b/hw/9pfs/9p-xattr.c
@@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,
     g_free(name);
     close_preserve_errno(dirfd);
     if (xattr_len < 0) {
+        g_free(orig_value);
         return -1;
     }
 
-- 
1.8.3.1


Re: [Qemu-devel] [PATCH] 9pfs: xattr: fix memory leak in v9fs_list_xattr
Posted by Greg Kurz 7 years ago
On Fri,  7 Apr 2017 03:48:52 -0700
Li Qiang <liq3ea@gmail.com> wrote:

> Free 'orig_value' in error path.
> 
> Signed-off-by: Li Qiang <liqiang6-s@360.cn>
> ---

Good catch. I'll send a pull req later today.

Cheers.

--
Greg

>  hw/9pfs/9p-xattr.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/9pfs/9p-xattr.c b/hw/9pfs/9p-xattr.c
> index eec160b..d05c1a1 100644
> --- a/hw/9pfs/9p-xattr.c
> +++ b/hw/9pfs/9p-xattr.c
> @@ -108,6 +108,7 @@ ssize_t v9fs_list_xattr(FsContext *ctx, const char *path,
>      g_free(name);
>      close_preserve_errno(dirfd);
>      if (xattr_len < 0) {
> +        g_free(orig_value);
>          return -1;
>      }
>