[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL trivial 03/11] hw/9pfs: Fix potential memory leak and
From: |
Michael Tokarev |
Subject: |
[Qemu-devel] [PULL trivial 03/11] hw/9pfs: Fix potential memory leak and avoid reuse of freed memory |
Date: |
Sat, 27 Jul 2013 11:33:18 +0400 |
From: Stefan Weil <address@hidden>
The leak was reported by cppcheck.
Function proxy_init also calls g_free for ctx->fs_root.
Avoid reuse of this memory by setting ctx->fs_root to NULL.
Signed-off-by: Stefan Weil <address@hidden>
Reviewed-by: M. Mohan Kumar <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
hw/9pfs/virtio-9p-proxy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/hw/9pfs/virtio-9p-proxy.c b/hw/9pfs/virtio-9p-proxy.c
index 8ba2959..5f44bb7 100644
--- a/hw/9pfs/virtio-9p-proxy.c
+++ b/hw/9pfs/virtio-9p-proxy.c
@@ -1153,10 +1153,12 @@ static int proxy_init(FsContext *ctx)
sock_id = atoi(ctx->fs_root);
if (sock_id < 0) {
fprintf(stderr, "socket descriptor not initialized\n");
+ g_free(proxy);
return -1;
}
}
g_free(ctx->fs_root);
+ ctx->fs_root = NULL;
proxy->in_iovec.iov_base = g_malloc(PROXY_MAX_IO_SZ + PROXY_HDR_SZ);
proxy->in_iovec.iov_len = PROXY_MAX_IO_SZ + PROXY_HDR_SZ;
--
1.7.10.4
- [Qemu-devel] [PULL trivial 00/11] trivial patches for 2013-07-27, Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 01/11] aes: Remove unused code (NDEBUG, u16), Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 06/11] PPC: dbdma: macio: Fix format specifiers (build regression), Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 03/11] hw/9pfs: Fix potential memory leak and avoid reuse of freed memory,
Michael Tokarev <=
- [Qemu-devel] [PULL trivial 07/11] linux-user: correct argument number for sys_mremap and sys_splice, Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 04/11] exec: Remove env from list of poisoned names, Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 05/11] watchdog: Remove break after exit, Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 02/11] timer: make timers_state static, Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 09/11] qemu-options: mention C-a h in the -nographic doc, Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 08/11] misc: Fix new typos in comments and strings, Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 10/11] misc: Use g_assert_not_reached for code which is expected to be unreachable, Michael Tokarev, 2013/07/27
- [Qemu-devel] [PULL trivial 11/11] target-mips: Remove assignment to a variable which is never used, Michael Tokarev, 2013/07/27
- Re: [Qemu-devel] [PULL trivial 00/11] trivial patches for 2013-07-27, Aurelien Jarno, 2013/07/29