diff options
author | Stefan Weil <sw@weilnetz.de> | 2013-06-16 12:14:36 +0200 |
---|---|---|
committer | Michael Tokarev <mjt@tls.msk.ru> | 2013-07-27 11:22:54 +0400 |
commit | 80cba1b71eb9a75404d1effddec8ffa9f0d6d6fb (patch) | |
tree | 87bfc77e1e1da2773a83a0605fcd595639209cbc | |
parent | d9cd4007d5c7e877a006392eeafb2291f06d6685 (diff) | |
download | hqemu-80cba1b71eb9a75404d1effddec8ffa9f0d6d6fb.zip hqemu-80cba1b71eb9a75404d1effddec8ffa9f0d6d6fb.tar.gz |
hw/9pfs: Fix potential memory leak and avoid reuse of freed memory
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 <sw@weilnetz.de>
Reviewed-by: M. Mohan Kumar <mohan@in.ibm.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
-rw-r--r-- | hw/9pfs/virtio-9p-proxy.c | 2 |
1 files changed, 2 insertions, 0 deletions
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; |