You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/linux-user
Daniel P. Berrangé 5171b794d4 linux-user: fix resource leaks in gen-vdso
There are a number of resource leaks in gen-vdso. In theory they are
harmless because this is a short lived process, but when building QEMU
with --extra-cflags="-fsanitize=address" problems ensure. The gen-vdso
program is run as part of the build, and that aborts due to the
sanitizer identifying memory leaks, leaving QEMU unbuildable.

FAILED: libqemu-x86_64-linux-user.a.p/vdso.c.inc
/var/home/berrange/src/virt/qemu/build/linux-user/gen-vdso -o libqemu-x86_64-linux-user.a.p/vdso.c.inc ../linux-user/x86_64/vdso.so

=================================================================
==1696332==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2968 byte(s) in 1 object(s) allocated from:
    #0 0x56495873f1f3  (/var/home/berrange/src/virt/qemu/build/linux-user/gen-vdso+0xa11f3) (BuildId: b69e241ad44719b6f3934f3c71dfc6727e8bdb12)
    #1 0x564958780b90  (/var/home/berrange/src/virt/qemu/build/linux-user/gen-vdso+0xe2b90) (BuildId: b69e241ad44719b6f3934f3c71dfc6727e8bdb12)

This complaint is about the 'buf' variable, however, the FILE objects
are also leaked in some error scenarios, so this fix refactors the
cleanup paths to fix all leaks. For completeness it also reports an
error if fclose() fails on 'inf'.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Tested-by: Arusekk <floss@arusekk.pl>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250513150346.1328217-1-berrange@redhat.com>
5 days ago
..
aarch64 linux-user/aarch64: Remove unused get/put_user macros 4 months ago
alpha user: Prefer cached CpuClass over CPU_GET_CLASS() macro 4 months ago
arm linux-user/arm: Fix return value of SYS_cacheflush 2 weeks ago
generic linux-user: Move TARGET_SA_RESTORER out of generic/signal.h 4 months ago
hexagon user: Move 'linux-user/cpu_loop-common.h' -> 'user/cpu_loop.h' 6 months ago
hppa linux-user/hppa: Send proper si_code on SIGFPE exception 1 month ago
i386 linux-user: Move TARGET_SA_RESTORER out of generic/signal.h 4 months ago
include
loongarch64 linux-user/loongarch64: Decode BRK break codes for FPE signals 2 months ago
m68k linux-user: Move TARGET_SA_RESTORER out of generic/signal.h 4 months ago
microblaze linux-user: Move TARGET_SA_RESTORER out of generic/signal.h 4 months ago
mips user: Move 'linux-user/cpu_loop-common.h' -> 'user/cpu_loop.h' 6 months ago
mips64
openrisc user: Move 'linux-user/cpu_loop-common.h' -> 'user/cpu_loop.h' 6 months ago
ppc linux-user: Move TARGET_SA_RESTORER out of generic/signal.h 4 months ago
riscv user: Move 'linux-user/cpu_loop-common.h' -> 'user/cpu_loop.h' 6 months ago
s390x linux-user: Move TARGET_SA_RESTORER out of generic/signal.h 4 months ago
sh4 linux-user: Move TARGET_SA_RESTORER out of generic/signal.h 4 months ago
sparc linux-user: Add missing /proc/cpuinfo fields for sparc 5 months ago
x86_64 linux-user: Move TARGET_SA_RESTORER out of generic/signal.h 4 months ago
xtensa cleanup: Drop pointless return at end of function 2 months ago
elfload.c linux-user/aarch64: Update hwcap bits from 6.14 5 days ago
errnos.c.inc
exit.c
fd-trans.c linux-user: netlink: Add missing QEMU_IFLA entries 5 months ago
fd-trans.h
flat.h
flatload.c include/exec: Split out mmap-lock.h 2 months ago
gen-vdso-elfn.c.inc linux-user: Fix GDB complaining about system-supplied DSO string table index 8 months ago
gen-vdso.c linux-user: fix resource leaks in gen-vdso 5 days ago
ioctls.h
linux_loop.h
linuxload.c
loader.h
main.c include/user: Convert GUEST_ADDR_MAX to a variable 2 months ago
meson.build plugins/api: split out binary path/start/end/entry code 4 months ago
mmap.c linux-user/mmap.c: fix "of of" typo in comment 2 months ago
plugin-api.c plugins/api: split out binary path/start/end/entry code 4 months ago
qemu.h exec: Restrict 'cpu_ldst.h' to accel/tcg/ 2 months ago
semihost.c
signal-common.h user: Introduce user/signal.h 5 months ago
signal.c accel/tcg: Use vaddr in cpu_loop.h 2 months ago
socket.h
strace.c linux-user: Fix strace output for s390x mmap() 7 months ago
strace.h
strace.list
syscall.c linux-user: implement pgid field of /proc/self/stat 1 month ago
syscall_defs.h exec/cpu-all: remove BSWAP_NEEDED 3 months ago
syscall_types.h
thunk.c
trace-events
trace.h
uaccess.c
uname.c
uname.h
user-internals.h include: Remove 'exec/exec-all.h' 2 months ago
user-mmap.h user: Extract common MMAP API to 'user/mmap.h' 4 months ago
vm86.c