[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
>
- [PULL 17/32] target/avr: Initialize TCG register variables, (continued)
- [PULL 17/32] target/avr: Initialize TCG register variables, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 16/32] target/avr: Add instruction translation - CPU main translation function, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 18/32] target/avr: Add support for disassembling via option '-d in_asm', Philippe Mathieu-Daudé, 2020/07/07
- [PULL 19/32] target/avr: Register AVR support with the rest of QEMU, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 20/32] tests/machine-none: Add AVR support, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 21/32] hw/char: avr: Add limited support for USART peripheral, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 22/32] hw/timer: avr: Add limited support for 16-bit timer peripheral, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 26/32] hw/avr: Add limited support for some Arduino boards, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 24/32] hw/avr: Add support for loading ELF/raw binaries, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 27/32] tests/boot-serial: Test some Arduino boards (AVR based), Philippe Mathieu-Daudé, 2020/07/07
- [PULL 23/32] hw/misc: avr: Add limited support for power reduction device, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 31/32] target/avr/cpu: Fix $PC displayed address, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 32/32] target/avr/disas: Fix store instructions display order, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 28/32] tests/acceptance: Test the Arduino MEGA2560 board, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 29/32] target/avr: Add section into QEMU documentation, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 25/32] hw/avr: Add some ATmega microcontrollers, Philippe Mathieu-Daudé, 2020/07/07
- [PULL 30/32] target/avr/cpu: Drop tlb_flush() in avr_cpu_reset(), Philippe Mathieu-Daudé, 2020/07/07
- Re: [PULL 00/32] AVR port, Peter Maydell, 2020/07/10