[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 01/26] hw/ppc/e500: Do not leak struct boot_info
From: |
Bernhard Beschow |
Subject: |
[PATCH v3 01/26] hw/ppc/e500: Do not leak struct boot_info |
Date: |
Sat, 2 Nov 2024 14:16:50 +0100 |
The struct is allocated once with g_new0() but never free()'d. Fix the leakage
by adding an attribute to struct PPCE500MachineState which avoids the
allocation.
While at it remove the obsolete /*< private >*/ markers.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/ppc/e500.h | 9 +++++++--
hw/ppc/e500.c | 17 ++++-------------
2 files changed, 11 insertions(+), 15 deletions(-)
diff --git a/hw/ppc/e500.h b/hw/ppc/e500.h
index 8c09ef92e4..4a1b42d44b 100644
--- a/hw/ppc/e500.h
+++ b/hw/ppc/e500.h
@@ -5,18 +5,23 @@
#include "hw/platform-bus.h"
#include "qom/object.h"
+struct boot_info {
+ uint32_t dt_base;
+ uint32_t dt_size;
+ uint32_t entry;
+};
+
struct PPCE500MachineState {
- /*< private >*/
MachineState parent_obj;
/* points to instance of TYPE_PLATFORM_BUS_DEVICE if
* board supports dynamic sysbus devices
*/
PlatformBusDevice *pbus_dev;
+ struct boot_info boot_info;
};
struct PPCE500MachineClass {
- /*< private >*/
MachineClass parent_class;
/* required -- must at least add toplevel board compatible */
diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c
index b760c6d6a2..ba83f33033 100644
--- a/hw/ppc/e500.c
+++ b/hw/ppc/e500.c
@@ -80,13 +80,6 @@
#define PLATFORM_CLK_FREQ_HZ (400 * 1000 * 1000)
-struct boot_info
-{
- uint32_t dt_base;
- uint32_t dt_size;
- uint32_t entry;
-};
-
static uint32_t *pci_map_create(void *fdt, uint32_t mpic, int first_slot,
int nr_slots, int *len)
{
@@ -919,7 +912,6 @@ void ppce500_init(MachineState *machine)
bool kernel_as_payload;
hwaddr bios_entry = 0;
target_long payload_size;
- struct boot_info *boot_info = NULL;
int dt_size;
int i;
unsigned int smp_cpus = machine->smp.cpus;
@@ -974,9 +966,8 @@ void ppce500_init(MachineState *machine)
/* Register reset handler */
if (!i) {
/* Primary CPU */
- boot_info = g_new0(struct boot_info, 1);
qemu_register_reset(ppce500_cpu_reset, cpu);
- env->load_info = boot_info;
+ env->load_info = &pms->boot_info;
} else {
/* Secondary CPUs */
qemu_register_reset(ppce500_cpu_reset_sec, cpu);
@@ -1274,9 +1265,9 @@ void ppce500_init(MachineState *machine)
}
assert(dt_size < DTB_MAX_SIZE);
- boot_info->entry = bios_entry;
- boot_info->dt_base = dt_base;
- boot_info->dt_size = dt_size;
+ pms->boot_info.entry = bios_entry;
+ pms->boot_info.dt_base = dt_base;
+ pms->boot_info.dt_size = dt_size;
}
static void e500_ccsr_initfn(Object *obj)
--
2.47.0
- [PATCH v3 00/26] E500 Cleanup, Bernhard Beschow, 2024/11/02
- [PATCH v3 02/26] hw/ppc/e500: Remove firstenv variable, Bernhard Beschow, 2024/11/02
- [PATCH v3 07/26] hw/ppc/e500: Use SysBusDevice API to access TYPE_CCSR's internal resources, Bernhard Beschow, 2024/11/02
- [PATCH v3 15/26] hw/net/fsl_etsec/miim: Reuse MII constants, Bernhard Beschow, 2024/11/02
- [PATCH v3 01/26] hw/ppc/e500: Do not leak struct boot_info,
Bernhard Beschow <=
- [PATCH v3 09/26] hw/ppc/ppce500_ccsr: Trace access to CCSR region, Bernhard Beschow, 2024/11/02
- [PATCH v3 10/26] hw/ppc/mpc8544_guts: Populate POR PLL ratio status register, Bernhard Beschow, 2024/11/02
- [PATCH v3 03/26] hw/ppc/e500: Prefer QOM cast, Bernhard Beschow, 2024/11/02
- [PATCH v3 05/26] hw/ppc/e500: Add missing device tree properties to i2c controller node, Bernhard Beschow, 2024/11/02
- [PATCH v3 04/26] hw/ppc/e500: Remove unused "irqs" parameter, Bernhard Beschow, 2024/11/02
- [PATCH v3 11/26] hw/i2c/mpc_i2c: Convert DPRINTF to trace events for register access, Bernhard Beschow, 2024/11/02
- [PATCH v3 06/26] hw/ppc/e500: Reuse TYPE_GPIO_PWR, Bernhard Beschow, 2024/11/02