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>
This commit is contained in:
Richard Henderson 2024-03-05 10:15:50 -10:00
parent 8de24b1563
commit b35348c7e6

View File

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