On Mon, Sep 1, 2025 at 3:54 PM Alex Bennée <[email protected]> wrote: > > The function has quite a number of exit cases so lets try and clean > things up with g_autofree. As the fdt hasn't be allocated yet we can > return directly from the fail point. > > Signed-off-by: Alex Bennée <[email protected]> > ---
Reviewed-by: Manos Pitsidianakis <[email protected]> > hw/arm/boot.c | 8 +++----- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/hw/arm/boot.c b/hw/arm/boot.c > index d391cd01bb1..56fd13b9f7c 100644 > --- a/hw/arm/boot.c > +++ b/hw/arm/boot.c > @@ -528,20 +528,18 @@ int arm_load_dtb(hwaddr addr, const struct > arm_boot_info *binfo, > Error *err = NULL; > > if (binfo->dtb_filename) { > - char *filename; > - filename = qemu_find_file(QEMU_FILE_TYPE_DTB, binfo->dtb_filename); > + g_autofree char *filename = qemu_find_file(QEMU_FILE_TYPE_DTB, > + binfo->dtb_filename); > if (!filename) { > fprintf(stderr, "Couldn't open dtb file %s\n", > binfo->dtb_filename); > - goto fail; > + return -1; > } > > fdt = load_device_tree(filename, &size); > if (!fdt) { > fprintf(stderr, "Couldn't open dtb file %s\n", filename); > - g_free(filename); > goto fail; > } > - g_free(filename); > } else { > fdt = binfo->get_dtb(binfo, &size); > if (!fdt) { > -- > 2.47.2 > >
