All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] target-sh4: Use glib allocator in movcal helper
@ 2016-07-12 12:50 Peter Maydell
  2016-07-21 12:44 ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2016-07-12 12:50 UTC (permalink / raw)
  To: qemu-devel; +Cc: patches, Aurelien Jarno

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] target-sh4: Use glib allocator in movcal helper
  2016-07-12 12:50 [Qemu-devel] [PATCH] target-sh4: Use glib allocator in movcal helper Peter Maydell
@ 2016-07-21 12:44 ` Peter Maydell
  2016-07-21 16:28   ` Aurelien Jarno
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Maydell @ 2016-07-21 12:44 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Aurelien Jarno, Patch Tracking

Ping?

thanks
-- PMM

On 12 July 2016 at 13:50, Peter Maydell <peter.maydell@linaro.org> wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] target-sh4: Use glib allocator in movcal helper
  2016-07-21 12:44 ` Peter Maydell
@ 2016-07-21 16:28   ` Aurelien Jarno
  2016-07-22 11:06     ` Peter Maydell
  0 siblings, 1 reply; 4+ messages in thread
From: Aurelien Jarno @ 2016-07-21 16:28 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Developers, Patch Tracking

On 2016-07-21 13:44, Peter Maydell wrote:
> Ping?
> 
> thanks
> -- PMM
> 
> On 12 July 2016 at 13:50, Peter Maydell <peter.maydell@linaro.org> wrote:
> > 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(-)

I have just looked at it and test it. It's all fine, sorry for the
delay.

Acked-by: Aurelien Jarno <aurelien@aurel32.net>

-- 
Aurelien Jarno                          GPG: 4096R/1DDD8C9B
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] target-sh4: Use glib allocator in movcal helper
  2016-07-21 16:28   ` Aurelien Jarno
@ 2016-07-22 11:06     ` Peter Maydell
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2016-07-22 11:06 UTC (permalink / raw)
  To: Aurelien Jarno; +Cc: QEMU Developers, Patch Tracking

On 21 July 2016 at 17:28, Aurelien Jarno <aurelien@aurel32.net> wrote:
> On 2016-07-21 13:44, Peter Maydell wrote:
>> Ping?
>>
>> thanks
>> -- PMM
>>
>> On 12 July 2016 at 13:50, Peter Maydell <peter.maydell@linaro.org> wrote:
>> > 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(-)
>
> I have just looked at it and test it. It's all fine, sorry for the
> delay.
>
> Acked-by: Aurelien Jarno <aurelien@aurel32.net>

Applied to master, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-07-22 11:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-12 12:50 [Qemu-devel] [PATCH] target-sh4: Use glib allocator in movcal helper Peter Maydell
2016-07-21 12:44 ` Peter Maydell
2016-07-21 16:28   ` Aurelien Jarno
2016-07-22 11:06     ` Peter Maydell

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.