diff mbox

s390: Plug memory leak on s390_pci_generate_event() error path

Message ID 1421747797-2762-1-git-send-email-armbru@redhat.com
State New
Headers show

Commit Message

Markus Armbruster Jan. 20, 2015, 9:56 a.m. UTC
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/s390x/s390-pci-bus.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini Jan. 20, 2015, 10:07 a.m. UTC | #1
On 20/01/2015 10:56, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/s390x/s390-pci-bus.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> index 1201b8d..d25ac74 100644
> --- a/hw/s390x/s390-pci-bus.c
> +++ b/hw/s390x/s390-pci-bus.c
> @@ -187,7 +187,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
>  static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
>                                      uint32_t fid, uint64_t faddr, uint32_t e)
>  {
> -    SeiContainer *sei_cont = g_malloc0(sizeof(SeiContainer));
> +    SeiContainer *sei_cont;
>      S390pciState *s = S390_PCI_HOST_BRIDGE(
>          object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
>  
> @@ -195,6 +195,7 @@ static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
>          return;
>      }
>  
> +    sei_cont = g_malloc0(sizeof(SeiContainer));
>      sei_cont->fh = fh;
>      sei_cont->fid = fid;
>      sei_cont->cc = cc;
> 

A patch for this had been sent already, though I prefer yours.

Paolo
Cornelia Huck Jan. 21, 2015, 9:54 a.m. UTC | #2
On Tue, 20 Jan 2015 10:56:37 +0100
Markus Armbruster <armbru@redhat.com> wrote:

> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/s390x/s390-pci-bus.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> index 1201b8d..d25ac74 100644
> --- a/hw/s390x/s390-pci-bus.c
> +++ b/hw/s390x/s390-pci-bus.c
> @@ -187,7 +187,7 @@ S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
>  static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
>                                      uint32_t fid, uint64_t faddr, uint32_t e)
>  {
> -    SeiContainer *sei_cont = g_malloc0(sizeof(SeiContainer));
> +    SeiContainer *sei_cont;
>      S390pciState *s = S390_PCI_HOST_BRIDGE(
>          object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
> 
> @@ -195,6 +195,7 @@ static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
>          return;
>      }
> 
> +    sei_cont = g_malloc0(sizeof(SeiContainer));
>      sei_cont->fh = fh;
>      sei_cont->fid = fid;
>      sei_cont->cc = cc;

Applied to my s390-next branch.
diff mbox

Patch

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 1201b8d..d25ac74 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -187,7 +187,7 @@  S390PCIBusDevice *s390_pci_find_dev_by_fh(uint32_t fh)
 static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
                                     uint32_t fid, uint64_t faddr, uint32_t e)
 {
-    SeiContainer *sei_cont = g_malloc0(sizeof(SeiContainer));
+    SeiContainer *sei_cont;
     S390pciState *s = S390_PCI_HOST_BRIDGE(
         object_resolve_path(TYPE_S390_PCI_HOST_BRIDGE, NULL));
 
@@ -195,6 +195,7 @@  static void s390_pci_generate_event(uint8_t cc, uint16_t pec, uint32_t fh,
         return;
     }
 
+    sei_cont = g_malloc0(sizeof(SeiContainer));
     sei_cont->fh = fh;
     sei_cont->fid = fid;
     sei_cont->cc = cc;