diff options
| author | Richard Henderson <richard.henderson@linaro.org> | 2024-03-05 10:15:50 -1000 |
|---|---|---|
| committer | Richard Henderson <richard.henderson@linaro.org> | 2024-03-12 03:36:19 -1000 |
| commit | b35348c7e62dc9b7caaabf3b45863ac119db9347 (patch) | |
| tree | 4527e6cca018fd1c3859a400a68c5a39ff69d487 | |
| parent | 8de24b15630a9b2d474be593289c8bf54dacd50a (diff) | |
| download | focaccia-qemu-b35348c7e62dc9b7caaabf3b45863ac119db9347.tar.gz focaccia-qemu-b35348c7e62dc9b7caaabf3b45863ac119db9347.zip | |
linux-user/elfload: Don't close an unopened file descriptor
Fixes Coverity CID: 1534964
Fixes: 106f8da664 ("linux-user/elfload: Open core file after vma_init")
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
| -rw-r--r-- | linux-user/elfload.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 4dbca05646..26d4c1d6b3 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -4522,7 +4522,9 @@ static int elf_core_dump(int signr, const CPUArchState *env) ret = -errno; mmap_unlock(); cpu_list_unlock(); - close(fd); + if (fd >= 0) { + close(fd); + } return ret; } #endif /* USE_ELF_CORE_DUMP */ |