Skip to contentSkip to conversation

ppc: fix double-free in cpu_post_load()

PATCH In review Greg Kurz 4 participants 4 messages Aug 2, 2017 – Aug 3, 2017

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 ppc: fix double-free in cpu_post_load()

When running nested with KVM PR, ppc_set_compat() fails and QEMU crashes because of "double free or corruption (!prev)". The crash happens because error_report_err() has already called error_free().

---
 target/ppc/machine.c |    1 -
 1 file changed, 1 deletion(-)
target/ppc/machine.c +0 -1
index f578156dd411..abe0a1cdf021 100644
@@ -239,7 +239,6 @@ static int cpu_post_load(void *opaque, int version_id)
         ppc_set_compat(cpu, cpu->compat_pvr, &local_err);
         if (local_err) {
             error_report_err(local_err);
-            error_free(local_err);
             return -1;
         }
     } else
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Greg Kurz

When running nested with KVM PR, ppc_set_compat() fails and QEMU crashes because of "double free or corruption (!prev)". The crash happens because error_report_err() has already called error_free().

---
 target/ppc/machine.c |    1 -
 1 file changed, 1 deletion(-)
Quoted 16 lines
target/ppc/machine.c +0 -1
index f578156dd411..abe0a1cdf021 100644
@@ -239,7 +239,6 @@ static int cpu_post_load(void *opaque, int version_id)
         ppc_set_compat(cpu, cpu->compat_pvr, &local_err);
         if (local_err) {
             error_report_err(local_err);
-            error_free(local_err);
             return -1;
         }
     } else
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/1
#2 lore raw
In reply to Greg Kurz
Quoted 5 lines · Greg Kurz

When running nested with KVM PR, ppc_set_compat() fails and QEMU crashes because of "double free or corruption (!prev)". The crash happens because error_report_err() has already called error_free().

Quoted 18 lines
---
  target/ppc/machine.c |    1 -
  1 file changed, 1 deletion(-)
target/ppc/machine.c +0 -1
index f578156dd411..abe0a1cdf021 100644
@@ -239,7 +239,6 @@ static int cpu_post_load(void *opaque, int version_id)
          ppc_set_compat(cpu, cpu->compat_pvr, &local_err);
          if (local_err) {
              error_report_err(local_err);
-            error_free(local_err);
              return -1;
          }
      } else
#3 lore raw
In reply to Greg Kurz
Quoted 5 lines · Greg Kurz

When running nested with KVM PR, ppc_set_compat() fails and QEMU crashes because of "double free or corruption (!prev)". The crash happens because error_report_err() has already called error_free().

Oops, that's a bit embarassing. Applied to ppc-for-2.10.

Quoted 17 lines
---
 target/ppc/machine.c |    1 -
 1 file changed, 1 deletion(-)
target/ppc/machine.c +0 -1
index f578156dd411..abe0a1cdf021 100644
@@ -239,7 +239,6 @@ static int cpu_post_load(void *opaque, int version_id)
         ppc_set_compat(cpu, cpu->compat_pvr, &local_err);
         if (local_err) {
             error_report_err(local_err);
-            error_free(local_err);
             return -1;
         }
     } else
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson