aboutsummaryrefslogtreecommitdiff
path: root/linux-user
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2024-03-05 10:15:50 -1000
committerRichard Henderson <richard.henderson@linaro.org>2024-03-12 03:36:19 -1000
commitb35348c7e62dc9b7caaabf3b45863ac119db9347 (patch)
tree4527e6cca018fd1c3859a400a68c5a39ff69d487 /linux-user
parent8de24b15630a9b2d474be593289c8bf54dacd50a (diff)
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>
Diffstat (limited to 'linux-user')
-rw-r--r--linux-user/elfload.c4
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 */