From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, Aurelien Jarno <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH] target-sh4: Use glib allocator in movcal helper
Date: Tue, 12 Jul 2016 13:50:59 +0100 [thread overview]
Message-ID: <1468327859-21385-1-git-send-email-peter.maydell@linaro.org> (raw)
Coverity spots that helper_movcal() calls malloc() but doesn't
check for failure. Fix this by switching to the glib allocation
functions, which abort on allocation failure.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target-sh4/op_helper.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/target-sh4/op_helper.c b/target-sh4/op_helper.c
index 303e83e..40dd1cf 100644
--- a/target-sh4/op_helper.c
+++ b/target-sh4/op_helper.c
@@ -109,7 +109,8 @@ void helper_movcal(CPUSH4State *env, uint32_t address, uint32_t value)
{
if (cpu_sh4_is_cached (env, address))
{
- memory_content *r = malloc (sizeof(memory_content));
+ memory_content *r = g_new(memory_content, 1);
+
r->address = address;
r->value = value;
r->next = NULL;
@@ -126,7 +127,7 @@ void helper_discard_movcal_backup(CPUSH4State *env)
while(current)
{
memory_content *next = current->next;
- free (current);
+ g_free(current);
env->movcal_backup = current = next;
if (current == NULL)
env->movcal_backup_tail = &(env->movcal_backup);
@@ -149,7 +150,7 @@ void helper_ocbi(CPUSH4State *env, uint32_t address)
env->movcal_backup_tail = current;
}
- free (*current);
+ g_free(*current);
*current = next;
break;
}
--
1.9.1
next reply other threads:[~2016-07-12 12:51 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-12 12:50 Peter Maydell [this message]
2016-07-21 12:44 ` [Qemu-devel] [PATCH] target-sh4: Use glib allocator in movcal helper Peter Maydell
2016-07-21 16:28 ` Aurelien Jarno
2016-07-22 11:06 ` 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=1468327859-21385-1-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=aurelien@aurel32.net \
--cc=patches@linaro.org \
--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 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).