From: ajia@redhat.com
To: qemu-devel@nongnu.org
Cc: Alex Jia <ajia@redhat.com>
Subject: [Qemu-devel] [PATCH v2] linux-user: fix memory leak in failure path
Date: Wed, 28 Sep 2011 16:24:41 +0800 [thread overview]
Message-ID: <1317198281-14922-1-git-send-email-ajia@redhat.com> (raw)
From: Alex Jia <ajia@redhat.com>
Haven't released memory of 'host_mb' in failure path, and calling malloc allocate
memory to 'host_array', however, memory hasn't been freed before the function
target_to_host_semarray returns.
Signed-off-by: Alex Jia <ajia@redhat.com>
---
linux-user/syscall.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7735008..22d4fcc 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2466,6 +2466,7 @@ static inline abi_long target_to_host_semarray(int semid, unsigned short **host_
for(i=0; i<nsems; i++) {
__get_user((*host_array)[i], &array[i]);
}
+ free(*host_array);
unlock_user(array, target_addr, 0);
return 0;
@@ -2779,9 +2780,9 @@ static inline abi_long do_msgrcv(int msqid, abi_long msgp,
}
target_mb->mtype = tswapl(host_mb->mtype);
- free(host_mb);
end:
+ free(host_mb);
if (target_mb)
unlock_user_struct(target_mb, msgp, 1);
return ret;
--
1.7.1
next reply other threads:[~2011-09-28 8:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-28 8:24 ajia [this message]
2011-09-28 9:43 ` [Qemu-devel] [PATCH v2] linux-user: fix memory leak in failure path Peter Maydell
2011-09-28 10:37 ` Alex Jia
2011-09-28 10:58 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1317198281-14922-1-git-send-email-ajia@redhat.com \
--to=ajia@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.