AVR patches for 2020-07-21
The following changes since commit 90218a9a393c7925f330e7dcc08658e2a01d3bd4:
Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-07=
-21' into staging (2020-07-21 10:24:38 +0100)
are available in the Git repository at:
https://gitlab.com/philmd/qemu.git tags/avr-20200721
for you to fetch changes up to 5e29521a82e540552880c3572cb8274bcaa1002c:
hw/avr/boot: Fix memory leak in avr_load_firmware() (2020-07-21 16:13:04 +0=
200)
----------------------------------------------------------------
AVR patches
Fixes a memory leak reported by Coverity (CID 1430449).
CI jobs result:
. https://gitlab.com/philmd/qemu/-/pipelines/168722631
----------------------------------------------------------------
Philippe Mathieu-Daud=C3=A9 (4):
qemu/osdep: Document os_find_datadir() return value qemu/osdep: Reword qemu_get_exec_dir() documentation
qemu-common: Document qemu_find_file() hw/avr/boot: Fix memory leak in avr_load_firmware()
include/qemu-common.h | 17 +++++++++++++++++ include/qemu/osdep.h | 5 ++++- hw/avr/boot.c | 2 +- os-posix.c | 3 +++ os-win32.c | 7 ++++++- 5 files changed, 31 insertions(+), 3 deletions(-)
--=20
2.21.3
[PULL 1/4] qemu/osdep: Document os_find_datadir() return value
Document os_find_datadir() returned data must be freed.
Message-Id: <[email protected]>
--- os-posix.c | 3 +++ os-win32.c | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
os-posix.c +3 -0
@@ -84,6 +84,9 @@ void os_setup_signal_handling(void)* Find a likely location for support files using the location of the binary. * When running from the build tree this will be "$bindir/../pc-bios". * Otherwise, this is CONFIG_QEMU_DATADIR. +* +* The caller must use g_free() to free the returned data when it is +* no longer required. */ char *os_find_datadir (void ) {
os-win32.c +6 -1
@@ -57,7 +57,12 @@ void os_setup_early_signal_handling(void)atexit (os_undo_timer_resolution); } -/* Look for support files in the same directory as the executable. */ +/* +* Look for support files in the same directory as the executable. +* +* The caller must use g_free() to free the returned data when it is +* no longer required. +*/ char *os_find_datadir (void ) {return qemu_get_exec_dir ();
Signature · 1 line
2.21.3
[PULL 3/4] qemu-common: Document qemu_find_file()
In reply to Philippe Mathieu-DaudéDocument qemu_find_file(), in particular the returned value which must be freed.
Message-Id: <[email protected]>
--- include/qemu-common.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
include/qemu-common.h +17 -0
@@ -110,6 +110,23 @@ const char *qemu_get_vm_name(void);#define QEMU_FILE_TYPE_BIOS 0#define QEMU_FILE_TYPE_KEYMAP 1 +/** +* qemu_find_file: +* @type: QEMU_FILE_TYPE_BIOS (for BIOS, VGA BIOS) +* or QEMU_FILE_TYPE_KEYMAP (for keymaps). +* @name: Relative or absolute file name +* +* If @name exists on disk as an absolute path, or a path relative +* to the current directory, then returns @name unchanged. +* Otherwise searches for @name file in the data directories, either +* configured at build time (DATADIR) or registered with the -L command +* line option. +* +* The caller must use g_free() to free the returned data when it is +* no longer required. +* +* Returns: a path that can access @name, or NULL if no matching file exists. +*/ char *qemu_find_file (int type,const char *name);/* OS specific functions */
Signature · 1 line
2.21.3
[PULL 2/4] qemu/osdep: Reword qemu_get_exec_dir() documentation
In reply to Philippe Mathieu-DaudéThis comment is confuse, reword it a bit.
Message-Id: <[email protected]>
--- include/qemu/osdep.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
include/qemu/osdep.h +4 -1
@@ -588,7 +588,10 @@ char *qemu_get_local_state_pathname(const char *relative_pathname);void qemu_init_exec_dir (const char *argv0);/* Get the saved exec dir. -* Caller needs to release the returned string by g_free() */ +* +* The caller is responsible for releasing the value returned with g_free() +* after use. +*/ char *qemu_get_exec_dir (void );/**
Signature · 1 line
2.21.3
[PULL 4/4] hw/avr/boot: Fix memory leak in avr_load_firmware()
In reply to Philippe Mathieu-DaudéThe value returned by qemu_find_file() must be freed.
This fixes Coverity issue CID 1430449, which points out that the memory returned by qemu_find_file() is leaked.
Message-Id: <[email protected]>
--- hw/avr/boot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/avr/boot.c +1 -1
@@ -60,7 +60,7 @@ static const char *avr_elf_e_flags_to_cpu_type(uint32_t flags)bool avr_load_firmware (AVRCPU *cpu,MachineState *ms,MemoryRegion *program_mr,const char *firmware) { -const char *filename; + g_autofree char *filename = NULL;int bytes_loaded;uint64_t entry;uint32_t e_flags;
Signature · 1 line
2.21.3
Peter Maydell
AppliedQuoted 15 lines · Philippe Mathieu-Daudé
The following changes since commit
90218a9a393c7925f330e7dcc08658e2a01d3bd4:Merge remote-tracking branch 'remotes/huth-gitlab/tags/pull-request-2020-07=
-21' into staging (2020-07-21 10:24:38 +0100)are available in the Git repository at:
https://gitlab.com/philmd/qemu.git tags/avr-20200721
for you to fetch changes up to
5e29521a82e540552880c3572cb8274bcaa1002c:hw/avr/boot: Fix memory leak in
avr_load_firmware()(2020-07-21 16:13:04 +0=
200)
Quoted 8 lines
----------------------------------------------------------------
AVR patchesFixes a memory leak reported by Coverity (CID 1430449).
CI jobs result:
. https://gitlab.com/philmd/qemu/-/pipelines/168722631
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/5.1
for any user-visible changes.
-- PMM