diff mbox series

[PULL,5/8] linux-user/elfload: Don't close an unopened file descriptor

Message ID 20240312184115.365415-6-richard.henderson@linaro.org
State New
Headers show
Series [PULL,1/8] linux-user: Add FIFREEZE and FITHAW ioctls | expand

Commit Message

Richard Henderson March 12, 2024, 6:41 p.m. UTC
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>
---
 linux-user/elfload.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

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 */