On 7/13/20 2:40 PM, Peter Maydell wrote: > On Tue, 7 Jul 2020 at 19:31, Philippe Mathieu-Daudé <f4...@amsat.org> wrote: >> >> Add avr_load_firmware() function to load firmware in ELF or >> raw binary format. > > Hi; Coverity points out a memory leak (CID 1430449) in this function: > >> +bool avr_load_firmware(AVRCPU *cpu, MachineState *ms, >> + MemoryRegion *program_mr, const char *firmware) >> +{ >> + const char *filename; >> + int bytes_loaded; >> + uint64_t entry; >> + uint32_t e_flags; >> + >> + filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, firmware); > > qemu_find_file() allocates and returns memory, but we don't > pass this to any function that takes ownership of it, > and none of the exit paths from the function (either error-exit > or success-exit cases) call g_free() on it.
Ah I didn't know it was allocated, I looked at the declaration in the header then quickly if there was a comment in the source, but didn't read the implementation (now I see the obvious g_strdup() call... Neither have I looked at the other callers. I'll send a patch. Thanks for following the Coverity reports, Phil. > > thanks > -- PMM >