* [Qemu-devel] [PATCH for-3.1] hw/ppc/mac_newworld: Free openpic_irqs array after use
@ 2018-11-01 16:17 Peter Maydell
2018-11-01 17:37 ` Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Peter Maydell @ 2018-11-01 16:17 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-ppc, David Gibson
In ppc_core99_init(), we allocate an openpic_irqs array, which
we then use to collect up the various qemu_irqs which we're
going to connect to the interrupt controller. Once we've
called sysbus_connect_irq() to connect them all up, the
array is no longer required, but we forgot to free it.
Since board init is only run once at startup, the memory
leak is not a significant one.
Spotted by Coverity: CID 1192916.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/ppc/mac_newworld.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index a630cb81cd8..14273a123e5 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -303,6 +303,7 @@ static void ppc_core99_init(MachineState *machine)
sysbus_connect_irq(s, k++, openpic_irqs[i][j]);
}
}
+ g_free(openpic_irqs);
if (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) {
/* 970 gets a U3 bus */
--
2.19.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH for-3.1] hw/ppc/mac_newworld: Free openpic_irqs array after use
2018-11-01 16:17 [Qemu-devel] [PATCH for-3.1] hw/ppc/mac_newworld: Free openpic_irqs array after use Peter Maydell
@ 2018-11-01 17:37 ` Philippe Mathieu-Daudé
2018-11-02 11:14 ` Mark Cave-Ayland
2018-11-03 12:59 ` David Gibson
2 siblings, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-01 17:37 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: qemu-ppc, David Gibson
On 1/11/18 17:17, Peter Maydell wrote:
> In ppc_core99_init(), we allocate an openpic_irqs array, which
> we then use to collect up the various qemu_irqs which we're
> going to connect to the interrupt controller. Once we've
> called sysbus_connect_irq() to connect them all up, the
> array is no longer required, but we forgot to free it.
>
> Since board init is only run once at startup, the memory
> leak is not a significant one.
>
> Spotted by Coverity: CID 1192916.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> hw/ppc/mac_newworld.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index a630cb81cd8..14273a123e5 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -303,6 +303,7 @@ static void ppc_core99_init(MachineState *machine)
> sysbus_connect_irq(s, k++, openpic_irqs[i][j]);
> }
> }
> + g_free(openpic_irqs);
>
> if (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) {
> /* 970 gets a U3 bus */
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH for-3.1] hw/ppc/mac_newworld: Free openpic_irqs array after use
2018-11-01 16:17 [Qemu-devel] [PATCH for-3.1] hw/ppc/mac_newworld: Free openpic_irqs array after use Peter Maydell
2018-11-01 17:37 ` Philippe Mathieu-Daudé
@ 2018-11-02 11:14 ` Mark Cave-Ayland
2018-11-02 11:19 ` Peter Maydell
2018-11-03 12:59 ` David Gibson
2 siblings, 1 reply; 5+ messages in thread
From: Mark Cave-Ayland @ 2018-11-02 11:14 UTC (permalink / raw)
To: Peter Maydell, qemu-devel; +Cc: qemu-ppc, David Gibson
On 01/11/2018 16:17, Peter Maydell wrote:
> In ppc_core99_init(), we allocate an openpic_irqs array, which
> we then use to collect up the various qemu_irqs which we're
> going to connect to the interrupt controller. Once we've
> called sysbus_connect_irq() to connect them all up, the
> array is no longer required, but we forgot to free it.
>
> Since board init is only run once at startup, the memory
> leak is not a significant one.
>
> Spotted by Coverity: CID 1192916.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> hw/ppc/mac_newworld.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index a630cb81cd8..14273a123e5 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -303,6 +303,7 @@ static void ppc_core99_init(MachineState *machine)
> sysbus_connect_irq(s, k++, openpic_irqs[i][j]);
> }
> }
> + g_free(openpic_irqs);
>
> if (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) {
> /* 970 gets a U3 bus */
>
Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
I did notice the generation of this 2D array for the OpenPIC controller whilst
converting the Mac machines over to qdev, but wasn't exactly sure what to do here so
I left it.
ATB,
Mark.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH for-3.1] hw/ppc/mac_newworld: Free openpic_irqs array after use
2018-11-02 11:14 ` Mark Cave-Ayland
@ 2018-11-02 11:19 ` Peter Maydell
0 siblings, 0 replies; 5+ messages in thread
From: Peter Maydell @ 2018-11-02 11:19 UTC (permalink / raw)
To: Mark Cave-Ayland; +Cc: QEMU Developers, qemu-ppc, David Gibson
On 2 November 2018 at 11:14, Mark Cave-Ayland
<mark.cave-ayland@ilande.co.uk> wrote:
> On 01/11/2018 16:17, Peter Maydell wrote:
>
>> In ppc_core99_init(), we allocate an openpic_irqs array, which
>> we then use to collect up the various qemu_irqs which we're
>> going to connect to the interrupt controller. Once we've
>> called sysbus_connect_irq() to connect them all up, the
>> array is no longer required, but we forgot to free it.
>>
>> Since board init is only run once at startup, the memory
>> leak is not a significant one.
>>
>> Spotted by Coverity: CID 1192916.
>>
>> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
>> ---
>> hw/ppc/mac_newworld.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
>> index a630cb81cd8..14273a123e5 100644
>> --- a/hw/ppc/mac_newworld.c
>> +++ b/hw/ppc/mac_newworld.c
>> @@ -303,6 +303,7 @@ static void ppc_core99_init(MachineState *machine)
>> sysbus_connect_irq(s, k++, openpic_irqs[i][j]);
>> }
>> }
>> + g_free(openpic_irqs);
>>
>> if (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) {
>> /* 970 gets a U3 bus */
>>
>
> Reviewed-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
>
> I did notice the generation of this 2D array for the OpenPIC controller whilst
> converting the Mac machines over to qdev, but wasn't exactly sure what to do here so
> I left it.
In some sense the array isn't really necessary at all -- instead
of "fill in array with things; create PIC; sysbus_connect_irq from array"
you could just do "create PIC; sysbus_connect_irq to things".
But for this patch I opted to just free the memory rather than
attempt more complicated refactoring.
thanks
-- PMM
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Qemu-devel] [PATCH for-3.1] hw/ppc/mac_newworld: Free openpic_irqs array after use
2018-11-01 16:17 [Qemu-devel] [PATCH for-3.1] hw/ppc/mac_newworld: Free openpic_irqs array after use Peter Maydell
2018-11-01 17:37 ` Philippe Mathieu-Daudé
2018-11-02 11:14 ` Mark Cave-Ayland
@ 2018-11-03 12:59 ` David Gibson
2 siblings, 0 replies; 5+ messages in thread
From: David Gibson @ 2018-11-03 12:59 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel, qemu-ppc
[-- Attachment #1: Type: text/plain, Size: 1319 bytes --]
On Thu, Nov 01, 2018 at 04:17:58PM +0000, Peter Maydell wrote:
> In ppc_core99_init(), we allocate an openpic_irqs array, which
> we then use to collect up the various qemu_irqs which we're
> going to connect to the interrupt controller. Once we've
> called sysbus_connect_irq() to connect them all up, the
> array is no longer required, but we forgot to free it.
>
> Since board init is only run once at startup, the memory
> leak is not a significant one.
>
> Spotted by Coverity: CID 1192916.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Applied, thanks.
> ---
> hw/ppc/mac_newworld.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
> index a630cb81cd8..14273a123e5 100644
> --- a/hw/ppc/mac_newworld.c
> +++ b/hw/ppc/mac_newworld.c
> @@ -303,6 +303,7 @@ static void ppc_core99_init(MachineState *machine)
> sysbus_connect_irq(s, k++, openpic_irqs[i][j]);
> }
> }
> + g_free(openpic_irqs);
>
> if (PPC_INPUT(env) == PPC_FLAGS_INPUT_970) {
> /* 970 gets a U3 bus */
--
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] 5+ messages in thread
end of thread, other threads:[~2018-11-04 3:24 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-01 16:17 [Qemu-devel] [PATCH for-3.1] hw/ppc/mac_newworld: Free openpic_irqs array after use Peter Maydell
2018-11-01 17:37 ` Philippe Mathieu-Daudé
2018-11-02 11:14 ` Mark Cave-Ayland
2018-11-02 11:19 ` Peter Maydell
2018-11-03 12:59 ` David Gibson
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.