Skip to content

Commit 53ce7b4

Browse files
committed
Merge remote-tracking branch 'remotes/philmd-gitlab/tags/avr-20200721' into staging
AVR patches Fixes a memory leak reported by Coverity (CID 1430449). CI jobs result: . https://gitlab.com/philmd/qemu/-/pipelines/168722631 # gpg: Signature made Tue 21 Jul 2020 19:00:03 BST # gpg: using RSA key FAABE75E12917221DCFD6BB2E3E32C2CDEADC0DE # gpg: Good signature from "Philippe Mathieu-Daudé (F4BUG) <[email protected]>" [full] # Primary key fingerprint: FAAB E75E 1291 7221 DCFD 6BB2 E3E3 2C2C DEAD C0DE * remotes/philmd-gitlab/tags/avr-20200721: hw/avr/boot: Fix memory leak in avr_load_firmware() qemu-common: Document qemu_find_file() qemu/osdep: Reword qemu_get_exec_dir() documentation qemu/osdep: Document os_find_datadir() return value Signed-off-by: Peter Maydell <[email protected]>
2 parents d0cc248 + 5e29521 commit 53ce7b4

File tree

5 files changed

+31
-3
lines changed

5 files changed

+31
-3
lines changed

hw/avr/boot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ static const char *avr_elf_e_flags_to_cpu_type(uint32_t flags)
6060
bool avr_load_firmware(AVRCPU *cpu, MachineState *ms,
6161
MemoryRegion *program_mr, const char *firmware)
6262
{
63-
const char *filename;
63+
g_autofree char *filename = NULL;
6464
int bytes_loaded;
6565
uint64_t entry;
6666
uint32_t e_flags;

include/qemu-common.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,23 @@ const char *qemu_get_vm_name(void);
110110

111111
#define QEMU_FILE_TYPE_BIOS 0
112112
#define QEMU_FILE_TYPE_KEYMAP 1
113+
/**
114+
* qemu_find_file:
115+
* @type: QEMU_FILE_TYPE_BIOS (for BIOS, VGA BIOS)
116+
* or QEMU_FILE_TYPE_KEYMAP (for keymaps).
117+
* @name: Relative or absolute file name
118+
*
119+
* If @name exists on disk as an absolute path, or a path relative
120+
* to the current directory, then returns @name unchanged.
121+
* Otherwise searches for @name file in the data directories, either
122+
* configured at build time (DATADIR) or registered with the -L command
123+
* line option.
124+
*
125+
* The caller must use g_free() to free the returned data when it is
126+
* no longer required.
127+
*
128+
* Returns: a path that can access @name, or NULL if no matching file exists.
129+
*/
113130
char *qemu_find_file(int type, const char *name);
114131

115132
/* OS specific functions */

include/qemu/osdep.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,10 @@ char *qemu_get_local_state_pathname(const char *relative_pathname);
588588
void qemu_init_exec_dir(const char *argv0);
589589

590590
/* Get the saved exec dir.
591-
* Caller needs to release the returned string by g_free() */
591+
*
592+
* The caller is responsible for releasing the value returned with g_free()
593+
* after use.
594+
*/
592595
char *qemu_get_exec_dir(void);
593596

594597
/**

os-posix.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ void os_setup_signal_handling(void)
8484
* Find a likely location for support files using the location of the binary.
8585
* When running from the build tree this will be "$bindir/../pc-bios".
8686
* Otherwise, this is CONFIG_QEMU_DATADIR.
87+
*
88+
* The caller must use g_free() to free the returned data when it is
89+
* no longer required.
8790
*/
8891
char *os_find_datadir(void)
8992
{

os-win32.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ void os_setup_early_signal_handling(void)
5757
atexit(os_undo_timer_resolution);
5858
}
5959

60-
/* Look for support files in the same directory as the executable. */
60+
/*
61+
* Look for support files in the same directory as the executable.
62+
*
63+
* The caller must use g_free() to free the returned data when it is
64+
* no longer required.
65+
*/
6166
char *os_find_datadir(void)
6267
{
6368
return qemu_get_exec_dir();

0 commit comments

Comments
 (0)