qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 0/2] 9p patches for 2.12 20180220
@ 2018-02-20 10:49 Greg Kurz
  2018-02-20 10:49 ` [Qemu-devel] [PULL 1/2] 9p: v9fs_path_copy() readability Greg Kurz
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Greg Kurz @ 2018-02-20 10:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Greg Kurz

The following changes since commit 299a2e6fac397be9b82c66583d53d1daaa3ffe6c:

  Merge remote-tracking branch 'remotes/marcel/tags/rdma-pull-request' into staging (2018-02-19 12:51:11 +0000)

are available in the git repository at:

  https://github.com/gkurz/qemu.git tags/for-upstream

for you to fetch changes up to 6ce7177ae2e547999ef9e6f467415963991e28da:

  9p: fix leak in synth_name_to_path() (2018-02-19 18:27:32 +0100)

----------------------------------------------------------------
Fix memory leak in synth backend.

----------------------------------------------------------------
Marc-André Lureau (2):
      9p: v9fs_path_copy() readability
      9p: fix leak in synth_name_to_path()

 hw/9pfs/9p-synth.c | 1 +
 hw/9pfs/9p.c       | 9 ++++-----
 hw/9pfs/9p.h       | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
-- 
2.13.6

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL 1/2] 9p: v9fs_path_copy() readability
  2018-02-20 10:49 [Qemu-devel] [PULL 0/2] 9p patches for 2.12 20180220 Greg Kurz
@ 2018-02-20 10:49 ` Greg Kurz
  2018-02-20 10:49 ` [Qemu-devel] [PULL 2/2] 9p: fix leak in synth_name_to_path() Greg Kurz
  2018-02-20 15:39 ` [Qemu-devel] [PULL 0/2] 9p patches for 2.12 20180220 Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Greg Kurz @ 2018-02-20 10:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Greg Kurz, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

lhs/rhs doesn't tell much about how argument are handled, dst/src is
and const arguments is clearer in my mind. Use g_memdup() while at it.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/9p.c | 9 ++++-----
 hw/9pfs/9p.h | 2 +-
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c
index 85a1ed8171a4..48fa48e72074 100644
--- a/hw/9pfs/9p.c
+++ b/hw/9pfs/9p.c
@@ -190,12 +190,11 @@ v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...)
     va_end(ap);
 }
 
-void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs)
+void v9fs_path_copy(V9fsPath *dst, const V9fsPath *src)
 {
-    v9fs_path_free(lhs);
-    lhs->data = g_malloc(rhs->size);
-    memcpy(lhs->data, rhs->data, rhs->size);
-    lhs->size = rhs->size;
+    v9fs_path_free(dst);
+    dst->size = src->size;
+    dst->data = g_memdup(src->data, src->size);
 }
 
 int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h
index 5ced427d861b..bad8ee719c4b 100644
--- a/hw/9pfs/9p.h
+++ b/hw/9pfs/9p.h
@@ -343,7 +343,7 @@ void coroutine_fn v9fs_reclaim_fd(V9fsPDU *pdu);
 void v9fs_path_init(V9fsPath *path);
 void v9fs_path_free(V9fsPath *path);
 void v9fs_path_sprintf(V9fsPath *path, const char *fmt, ...);
-void v9fs_path_copy(V9fsPath *lhs, V9fsPath *rhs);
+void v9fs_path_copy(V9fsPath *dst, const V9fsPath *src);
 int v9fs_name_to_path(V9fsState *s, V9fsPath *dirpath,
                       const char *name, V9fsPath *path);
 int v9fs_device_realize_common(V9fsState *s, const V9fsTransport *t,
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL 2/2] 9p: fix leak in synth_name_to_path()
  2018-02-20 10:49 [Qemu-devel] [PULL 0/2] 9p patches for 2.12 20180220 Greg Kurz
  2018-02-20 10:49 ` [Qemu-devel] [PULL 1/2] 9p: v9fs_path_copy() readability Greg Kurz
@ 2018-02-20 10:49 ` Greg Kurz
  2018-02-20 15:39 ` [Qemu-devel] [PULL 0/2] 9p patches for 2.12 20180220 Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Greg Kurz @ 2018-02-20 10:49 UTC (permalink / raw)
  To: qemu-devel; +Cc: Peter Maydell, Greg Kurz, Marc-André Lureau

From: Marc-André Lureau <marcandre.lureau@redhat.com>

Leak found thanks to ASAN:

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x55995789ac90 in __interceptor_malloc (/home/elmarco/src/qemu/build/x86_64-softmmu/qemu-system-x86_64+0x1510c90)
    #1 0x7f0a91190f0c in g_malloc /home/elmarco/src/gnome/glib/builddir/../glib/gmem.c:94
    #2 0x5599580a281c in v9fs_path_copy /home/elmarco/src/qemu/hw/9pfs/9p.c:196:17
    #3 0x559958f9ec5d in coroutine_trampoline /home/elmarco/src/qemu/util/coroutine-ucontext.c:116:9
    #4 0x7f0a8766ebbf  (/lib64/libc.so.6+0x50bbf)

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/9pfs/9p-synth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c
index 18082dffe865..54239c9bbf32 100644
--- a/hw/9pfs/9p-synth.c
+++ b/hw/9pfs/9p-synth.c
@@ -495,6 +495,7 @@ static int synth_name_to_path(FsContext *ctx, V9fsPath *dir_path,
     }
 out:
     /* Copy the node pointer to fid */
+    g_free(target->data);
     target->data = g_memdup(&node, sizeof(void *));
     target->size = sizeof(void *);
     return 0;
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PULL 0/2] 9p patches for 2.12 20180220
  2018-02-20 10:49 [Qemu-devel] [PULL 0/2] 9p patches for 2.12 20180220 Greg Kurz
  2018-02-20 10:49 ` [Qemu-devel] [PULL 1/2] 9p: v9fs_path_copy() readability Greg Kurz
  2018-02-20 10:49 ` [Qemu-devel] [PULL 2/2] 9p: fix leak in synth_name_to_path() Greg Kurz
@ 2018-02-20 15:39 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2018-02-20 15:39 UTC (permalink / raw)
  To: Greg Kurz; +Cc: QEMU Developers

On 20 February 2018 at 10:49, Greg Kurz <groug@kaod.org> wrote:
> The following changes since commit 299a2e6fac397be9b82c66583d53d1daaa3ffe6c:
>
>   Merge remote-tracking branch 'remotes/marcel/tags/rdma-pull-request' into staging (2018-02-19 12:51:11 +0000)
>
> are available in the git repository at:
>
>   https://github.com/gkurz/qemu.git tags/for-upstream
>
> for you to fetch changes up to 6ce7177ae2e547999ef9e6f467415963991e28da:
>
>   9p: fix leak in synth_name_to_path() (2018-02-19 18:27:32 +0100)
>
> ----------------------------------------------------------------
> Fix memory leak in synth backend.
>
> ----------------------------------------------------------------
> Marc-André Lureau (2):
>       9p: v9fs_path_copy() readability
>       9p: fix leak in synth_name_to_path()
>
>  hw/9pfs/9p-synth.c | 1 +
>  hw/9pfs/9p.c       | 9 ++++-----
>  hw/9pfs/9p.h       | 2 +-
>  3 files changed, 6 insertions(+), 6 deletions(-)
> --

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-20 15:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-20 10:49 [Qemu-devel] [PULL 0/2] 9p patches for 2.12 20180220 Greg Kurz
2018-02-20 10:49 ` [Qemu-devel] [PULL 1/2] 9p: v9fs_path_copy() readability Greg Kurz
2018-02-20 10:49 ` [Qemu-devel] [PULL 2/2] 9p: fix leak in synth_name_to_path() Greg Kurz
2018-02-20 15:39 ` [Qemu-devel] [PULL 0/2] 9p patches for 2.12 20180220 Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).