Skip to contentSkip to conversation

spapr: Fix memory leak in h_client_architecture_support()

PATCH Applied Greg Kurz 3 participants 3 messages Mar 21, 2020 – Mar 22, 2020

lore
Share & tools
lore

Greg Kurz

author
#0 lore raw

PATCH 1/1 spapr: Fix memory leak in h_client_architecture_support()

This is the only error path that needs to free the previously allocated ov1.

Reported-by Coverity (CID 1421924)
Fixes cbd0d7f36322 "spapr: Fail CAS if option vector table cannot be parsed"
---
 hw/ppc/spapr_hcall.c |    1 +
 1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +1 -0
index 40c86e91eb89..0d50fc911790 100644
@@ -1726,6 +1726,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
     }
     ov5_guest = spapr_ovec_parse_vector(ov_table, 5);
     if (!ov5_guest) {
+        spapr_ovec_cleanup(ov1_guest);
         warn_report("guest didn't provide option vector 5");
         return H_PARAMETER;
     }
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Greg Kurz

This is the only error path that needs to free the previously allocated ov1.

Reported-by Coverity (CID 1421924)
Fixes cbd0d7f36322 "spapr: Fail CAS if option vector table cannot be parsed"
---
  hw/ppc/spapr_hcall.c |    1 +
  1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +0 -0
index 40c86e91eb89..0d50fc911790 100644

hw/ppc/spapr_hcall.c static target_ulong h_client_architecture_support(PowerPCCPU *cpu, · line 1729

Quoted 4 lines
hw/ppc/spapr_hcall.c +1 -0
@@ -1726,6 +1726,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
      }
      ov5_guest = spapr_ovec_parse_vector(ov_table, 5);
      if (!ov5_guest) {
+        spapr_ovec_cleanup(ov1_guest);

Quicker than using g_autoptr(), so for 5.0:

Quoted 4 lines
hw/ppc/spapr_hcall.c +0 -0
          warn_report("guest didn't provide option vector 5");
          return H_PARAMETER;
      }
Applied
#2 lore raw
In reply to Greg Kurz
Quoted 6 lines · Greg Kurz

This is the only error path that needs to free the previously allocated ov1.

Reported-by Coverity (CID 1421924)
Fixes cbd0d7f36322 "spapr: Fail CAS if option vector table cannot be parsed"

Applied to ppc-forr-5.0.

Quoted 17 lines
---
 hw/ppc/spapr_hcall.c |    1 +
 1 file changed, 1 insertion(+)
hw/ppc/spapr_hcall.c +1 -0
index 40c86e91eb89..0d50fc911790 100644
@@ -1726,6 +1726,7 @@ static target_ulong h_client_architecture_support(PowerPCCPU *cpu,
     }
     ov5_guest = spapr_ovec_parse_vector(ov_table, 5);
     if (!ov5_guest) {
+        spapr_ovec_cleanup(ov1_guest);
         warn_report("guest didn't provide option vector 5");
         return H_PARAMETER;
     }
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