qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PULL 24/32] hw/avr: Add support for loading ELF/raw binaries


From: Philippe Mathieu-Daudé
Subject: Re: [PULL 24/32] hw/avr: Add support for loading ELF/raw binaries
Date: Tue, 14 Jul 2020 17:09:04 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0

On 7/13/20 2:40 PM, Peter Maydell wrote:
> On Tue, 7 Jul 2020 at 19:31, Philippe Mathieu-Daudé <f4bug@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
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]