[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 12/14] spapr_pci_nvlink2.c: use g_autofree in spapr_phb_nvgpu_ram
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH 12/14] spapr_pci_nvlink2.c: use g_autofree in spapr_phb_nvgpu_ram_populate_dt() |
Date: |
Mon, 28 Feb 2022 14:50:02 -0300 |
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
hw/ppc/spapr_pci_nvlink2.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/hw/ppc/spapr_pci_nvlink2.c b/hw/ppc/spapr_pci_nvlink2.c
index 7fb0cf4d04..4678c79235 100644
--- a/hw/ppc/spapr_pci_nvlink2.c
+++ b/hw/ppc/spapr_pci_nvlink2.c
@@ -320,7 +320,7 @@ void spapr_phb_nvgpu_populate_dt(SpaprPhbState *sphb, void
*fdt, int bus_off,
void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState *sphb, void *fdt)
{
int i, j, linkidx, npuoff;
- char *npuname;
+ g_autofree char *npuname = NULL;
if (!sphb->nvgpus) {
return;
@@ -333,11 +333,10 @@ void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState *sphb,
void *fdt)
_FDT(fdt_setprop_cell(fdt, npuoff, "#size-cells", 0));
/* Advertise NPU as POWER9 so the guest can enable NPU2 contexts */
_FDT((fdt_setprop_string(fdt, npuoff, "compatible", "ibm,power9-npu")));
- g_free(npuname);
for (i = 0, linkidx = 0; i < sphb->nvgpus->num; ++i) {
for (j = 0; j < sphb->nvgpus->slots[i].linknum; ++j) {
- char *linkname = g_strdup_printf("link@%d", linkidx);
+ g_autofree char *linkname = g_strdup_printf("link@%d", linkidx);
int off = fdt_add_subnode(fdt, npuoff, linkname);
_FDT(off);
@@ -347,7 +346,6 @@ void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState *sphb,
void *fdt)
_FDT((fdt_setprop_cell(fdt, off, "phandle",
PHANDLE_NVLINK(sphb, i, j))));
_FDT((fdt_setprop_cell(fdt, off, "ibm,npu-link-index", linkidx)));
- g_free(linkname);
++linkidx;
}
}
@@ -360,7 +358,8 @@ void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState *sphb,
void *fdt)
&error_abort);
uint64_t size = object_property_get_uint(nv_mrobj, "size", NULL);
uint64_t mem_reg[2] = { cpu_to_be64(nvslot->gpa), cpu_to_be64(size) };
- char *mem_name = g_strdup_printf("memory@%"PRIx64, nvslot->gpa);
+ g_autofree char *mem_name = g_strdup_printf("memory@%"PRIx64,
+ nvslot->gpa);
int off = fdt_add_subnode(fdt, 0, mem_name);
_FDT(off);
@@ -378,7 +377,6 @@ void spapr_phb_nvgpu_ram_populate_dt(SpaprPhbState *sphb,
void *fdt)
sizeof(mem_reg))));
_FDT((fdt_setprop_cell(fdt, off, "phandle",
PHANDLE_GPURAM(sphb, i))));
- g_free(mem_name);
}
}
--
2.35.1
- [PATCH 02/14] hw/ppc/spapr.c: fail early if no firmware found in machine_init(), (continued)
- [PATCH 02/14] hw/ppc/spapr.c: fail early if no firmware found in machine_init(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 04/14] hw/ppc/spapr_caps.c: use g_autofree in spapr_cap_get_string(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 05/14] hw/ppc/spapr_caps.c: use g_autofree in spapr_caps_add_properties(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 06/14] hw/ppc/spapr_drc.c: use g_auto in spapr_dt_drc(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 07/14] hw/ppc/spapr_drc.c: use g_autofree in drc_realize(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 08/14] hw/ppc/spapr_drc.c: use g_autofree in drc_unrealize(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 09/14] hw/ppc/spapr_drc.c: use g_autofree in spapr_dr_connector_new(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 10/14] hw/ppc/spapr_drc.c: use g_autofree in spapr_drc_by_index(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 14/14] hw/ppc/spapr_vio.c: use g_autofree in spapr_dt_vdevice(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 13/14] hw/ppc/spapr_rtas.c: use g_autofree in rtas_ibm_get_system_parameter(), Daniel Henrique Barboza, 2022/02/28
- [PATCH 12/14] spapr_pci_nvlink2.c: use g_autofree in spapr_phb_nvgpu_ram_populate_dt(),
Daniel Henrique Barboza <=
- [PATCH 11/14] hw/ppc/spapr_numa.c: simplify spapr_numa_write_assoc_lookup_arrays(), Daniel Henrique Barboza, 2022/02/28
- Re: [PATCH 00/14] simple cleanups in spapr files, Philippe Mathieu-Daudé, 2022/02/28