qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] spapr: Fix memory leak in h_client_architecture_support()
@ 2020-03-21 17:34 Greg Kurz
  2020-03-21 18:06 ` Philippe Mathieu-Daudé
  2020-03-22  5:32 ` David Gibson
  0 siblings, 2 replies; 3+ messages in thread
From: Greg Kurz @ 2020-03-21 17:34 UTC (permalink / raw)
  To: David Gibson
  Cc: Peter Maydell, qemu-ppc, qemu-devel, Philippe Mathieu-Daudé

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"
Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/ppc/spapr_hcall.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
index 40c86e91eb89..0d50fc911790 100644
--- a/hw/ppc/spapr_hcall.c
+++ b/hw/ppc/spapr_hcall.c
@@ -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;
     }



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

* Re: [PATCH] spapr: Fix memory leak in h_client_architecture_support()
  2020-03-21 17:34 [PATCH] spapr: Fix memory leak in h_client_architecture_support() Greg Kurz
@ 2020-03-21 18:06 ` Philippe Mathieu-Daudé
  2020-03-22  5:32 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-03-21 18:06 UTC (permalink / raw)
  To: Greg Kurz, David Gibson; +Cc: Peter Maydell, qemu-ppc, qemu-devel

On 3/21/20 6:34 PM, Greg Kurz wrote:
> 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"
> Signed-off-by: Greg Kurz <groug@kaod.org>
> ---
>   hw/ppc/spapr_hcall.c |    1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index 40c86e91eb89..0d50fc911790 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -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:

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

>           warn_report("guest didn't provide option vector 5");
>           return H_PARAMETER;
>       }
> 



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

* Re: [PATCH] spapr: Fix memory leak in h_client_architecture_support()
  2020-03-21 17:34 [PATCH] spapr: Fix memory leak in h_client_architecture_support() Greg Kurz
  2020-03-21 18:06 ` Philippe Mathieu-Daudé
@ 2020-03-22  5:32 ` David Gibson
  1 sibling, 0 replies; 3+ messages in thread
From: David Gibson @ 2020-03-22  5:32 UTC (permalink / raw)
  To: Greg Kurz
  Cc: Peter Maydell, qemu-ppc, qemu-devel, Philippe Mathieu-Daudé

[-- Attachment #1: Type: text/plain, Size: 1121 bytes --]

On Sat, Mar 21, 2020 at 06:34:22PM +0100, Greg Kurz wrote:
> 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"
> Signed-off-by: Greg Kurz <groug@kaod.org>

Applied to ppc-forr-5.0.

> ---
>  hw/ppc/spapr_hcall.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c
> index 40c86e91eb89..0d50fc911790 100644
> --- a/hw/ppc/spapr_hcall.c
> +++ b/hw/ppc/spapr_hcall.c
> @@ -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;
>      }
> 

-- 
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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2020-03-22  5:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-21 17:34 [PATCH] spapr: Fix memory leak in h_client_architecture_support() Greg Kurz
2020-03-21 18:06 ` Philippe Mathieu-Daudé
2020-03-22  5:32 ` David Gibson

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).