qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] hw/riscv: fix leak, add more g_autofree
@ 2024-01-22 22:15 Daniel Henrique Barboza
  2024-01-22 22:15 ` [PATCH 1/7] hw/riscv/virt-acpi-build.c: fix leak in build_rhct() Daniel Henrique Barboza
                   ` (7 more replies)
  0 siblings, 8 replies; 19+ messages in thread
From: Daniel Henrique Barboza @ 2024-01-22 22:15 UTC (permalink / raw)
  To: qemu-devel
  Cc: qemu-riscv, alistair.francis, bmeng, liwei1518, zhiwei_liu,
	palmer, Daniel Henrique Barboza

Hi,

First patch fixes a leak found when using Valgrind. The root cause is a
missing g_free() in a string. 

In fact, I found while doing reviews that we keep repeating the same
pattern:

====
char *name;
name = g_strdup_printf(...);
(...)
g_free(name);
====

With this in mind, I ended up making this rather trivial series to
introduce more string/array autocleaning in the 'virt' machine code. The
advantage of doing 'g_autofree' is that we'll guarantee that we'll clean
ourselves up when the variable goes out of scope, avoiding leaks like
the one patch 1 fixes. We want to enforce this autoclean style in
reviews, and for that we need to get rid of at least some of the uses we
do it right now.

I didn't bother changing the 'spike' and the 'sifive' boards for now
because the bulk of new patches is done on top of the 'virt' machine,
so it's more important to tidy this board first.


Daniel Henrique Barboza (7):
  hw/riscv/virt-acpi-build.c: fix leak in build_rhct()
  hw/riscv/numa.c: use g_autofree in socket_fdt_write_distance_matrix()
  hw/riscv/virt.c: use g_autofree in create_fdt_socket_cpus()
  hw/riscv/virt.c: use g_autofree in create_fdt_sockets()
  hw/riscv/virt.c: use g_autofree in create_fdt_virtio()
  hw/riscv/virt.c: use g_autofree in virt_machine_init()
  hw/riscv/virt.c: use g_autofree in create_fdt_*

 hw/riscv/numa.c            |   4 +-
 hw/riscv/virt-acpi-build.c |   2 +-
 hw/riscv/virt.c            | 109 ++++++++++++-------------------------
 3 files changed, 37 insertions(+), 78 deletions(-)

-- 
2.43.0



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

end of thread, other threads:[~2024-02-05  3:18 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-22 22:15 [PATCH 0/7] hw/riscv: fix leak, add more g_autofree Daniel Henrique Barboza
2024-01-22 22:15 ` [PATCH 1/7] hw/riscv/virt-acpi-build.c: fix leak in build_rhct() Daniel Henrique Barboza
2024-02-05  2:57   ` Alistair Francis
2024-01-22 22:15 ` [PATCH 2/7] hw/riscv/numa.c: use g_autofree in socket_fdt_write_distance_matrix() Daniel Henrique Barboza
2024-02-05  2:57   ` Alistair Francis
2024-01-22 22:15 ` [PATCH 3/7] hw/riscv/virt.c: use g_autofree in create_fdt_socket_cpus() Daniel Henrique Barboza
2024-01-23  5:42   ` Philippe Mathieu-Daudé
2024-02-05  2:58   ` Alistair Francis
2024-01-22 22:15 ` [PATCH 4/7] hw/riscv/virt.c: use g_autofree in create_fdt_sockets() Daniel Henrique Barboza
2024-02-05  2:59   ` Alistair Francis
2024-01-22 22:15 ` [PATCH 5/7] hw/riscv/virt.c: use g_autofree in create_fdt_virtio() Daniel Henrique Barboza
2024-01-23  5:43   ` Philippe Mathieu-Daudé
2024-02-05  3:00   ` Alistair Francis
2024-01-22 22:15 ` [PATCH 6/7] hw/riscv/virt.c: use g_autofree in virt_machine_init() Daniel Henrique Barboza
2024-01-23  5:44   ` Philippe Mathieu-Daudé
2024-02-05  3:00   ` Alistair Francis
2024-01-22 22:15 ` [PATCH 7/7] hw/riscv/virt.c: use g_autofree in create_fdt_* Daniel Henrique Barboza
2024-02-05  3:02   ` Alistair Francis
2024-02-05  3:16 ` [PATCH 0/7] hw/riscv: fix leak, add more g_autofree Alistair Francis

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