From: Peter Maydell <peter.maydell@linaro.org>
To: Jim Meyering <jim@meyering.net>
Cc: "Anthony Liguori" <aliguori@us.ibm.com>,
"Jim Meyering" <meyering@redhat.com>,
qemu-devel@nongnu.org, "Stefan Weil" <weil@mail.berlios.de>,
"Andreas F=E4rber" <andreas.faerber@web.de>,
"Andreas Färber" <afaerber@suse.de>,
"Matthew Fernandez" <matthew.fernandez@gmail.com>
Subject: Re: [Qemu-devel] [PATCH 6/6] softmmu-semi: fix lock_user* functions not to deref NULL upon OOM
Date: Sat, 19 May 2012 16:46:44 +0100 [thread overview]
Message-ID: <CAFEAcA-PS9j5EqPb=ku5HRDQSy7XT6=zOAe21vkpTHG0f_9geA@mail.gmail.com> (raw)
In-Reply-To: <1337173681-25891-7-git-send-email-jim@meyering.net>
On 16 May 2012 14:08, Jim Meyering <jim@meyering.net> wrote:
> From: Jim Meyering <meyering@redhat.com>
>
> Use g_malloc/g_free in place of malloc/free.
>
> Signed-off-by: Jim Meyering <meyering@redhat.com>
> ---
> softmmu-semi.h | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/softmmu-semi.h b/softmmu-semi.h
> index 648cb95..996e0f7 100644
> --- a/softmmu-semi.h
> +++ b/softmmu-semi.h
> @@ -39,7 +39,7 @@ static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len,
> {
> uint8_t *p;
> /* TODO: Make this something that isn't fixed size. */
> - p = malloc(len);
> + p = g_malloc(len);
> if (copy)
> cpu_memory_rw_debug(env, addr, p, len, 0);
> return p;
Nak. This function is called with a length passed from the guest, so
killing qemu if the length is too large is a bad idea. The callers
should handle it returning NULL on failure. (Most of them do already,
if any do not that's a bug.) The bug in this function is passing
NULL to cpu_memory_rw_debug().
-- PMM
next prev parent reply other threads:[~2012-05-19 15:46 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-16 13:07 [Qemu-devel] [PATCH 0/6] plug memory and file-descriptor leaks Jim Meyering
2012-05-16 13:07 ` [Qemu-devel] [PATCH 1/6] qcow2: don't leak buffer for unexpected qcow_version in header Jim Meyering
2012-05-21 10:57 ` Kevin Wolf
2012-05-21 11:06 ` [Qemu-devel] [PATCHv2 " Jim Meyering
2012-05-21 11:24 ` Kevin Wolf
2012-05-21 11:07 ` [Qemu-devel] [PATCH " Jim Meyering
2012-05-16 13:07 ` [Qemu-devel] [PATCH 2/6] qemu-ga: avoid unconditional lockfile file descriptor leak Jim Meyering
2012-05-16 18:15 ` Michael Roth
2012-05-16 20:17 ` Jim Meyering
2012-05-16 20:19 ` [Qemu-devel] [PATCHv2 2/6] qemu-ga: don't leak a file descriptor upon failed lockf Jim Meyering
2012-05-16 20:58 ` Michael Roth
2012-05-16 13:07 ` [Qemu-devel] [PATCH 3/6] linux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failure Jim Meyering
2012-05-16 13:21 ` Peter Maydell
2012-05-16 13:50 ` Jim Meyering
2012-05-16 13:52 ` [Qemu-devel] [PATCHv2 " Jim Meyering
2012-05-16 13:07 ` [Qemu-devel] [PATCH 4/6] sheepdog: don't leak socket file descriptor upon connection failure Jim Meyering
2012-05-21 11:00 ` Kevin Wolf
2012-08-17 13:30 ` Jim Meyering
2012-08-17 13:40 ` Kevin Wolf
2012-08-17 13:42 ` Jim Meyering
2012-05-16 13:08 ` [Qemu-devel] [PATCH 5/6] arm-semi: don't leak 1kb user string lock buffer upon TARGET_SYS_OPEN Jim Meyering
2012-05-16 13:15 ` Peter Maydell
2012-05-16 13:08 ` [Qemu-devel] [PATCH 6/6] softmmu-semi: fix lock_user* functions not to deref NULL upon OOM Jim Meyering
2012-05-19 7:13 ` Matthew Fernandez
2012-05-19 15:46 ` Peter Maydell [this message]
2012-05-24 14:46 ` Jim Meyering
2012-05-24 14:46 ` [Qemu-devel] [PATCH v2 " Jim Meyering
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='CAFEAcA-PS9j5EqPb=ku5HRDQSy7XT6=zOAe21vkpTHG0f_9geA@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=afaerber@suse.de \
--cc=aliguori@us.ibm.com \
--cc=andreas.faerber@web.de \
--cc=jim@meyering.net \
--cc=matthew.fernandez@gmail.com \
--cc=meyering@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=weil@mail.berlios.de \
/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 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).