mirror of https://github.com/xemu-project/xemu.git
linux-user/elfload: Latch errno before cleanup in elf_core_dump
On the off-chance that one of the cleanup functions changes errno, latch the errno that we want to return beforehand. Flush errno to 0 upon success, rather than at the beginning. No need to avoid negation of 0. Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
0af22a6abf
commit
ccb6f3eee0
|
@ -4634,8 +4634,7 @@ static int elf_core_dump(int signr, const CPUArchState *env)
|
||||||
off_t offset = 0, data_offset = 0;
|
off_t offset = 0, data_offset = 0;
|
||||||
int segs = 0;
|
int segs = 0;
|
||||||
int fd = -1;
|
int fd = -1;
|
||||||
|
int ret;
|
||||||
errno = 0;
|
|
||||||
|
|
||||||
if (prctl(PR_GET_DUMPABLE) == 0) {
|
if (prctl(PR_GET_DUMPABLE) == 0) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -4755,15 +4754,14 @@ static int elf_core_dump(int signr, const CPUArchState *env)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
ret = -errno;
|
||||||
free_note_info(&info);
|
free_note_info(&info);
|
||||||
vma_delete(&mm);
|
vma_delete(&mm);
|
||||||
(void) close(fd);
|
close(fd);
|
||||||
|
return ret;
|
||||||
if (errno != 0)
|
|
||||||
return (-errno);
|
|
||||||
return (0);
|
|
||||||
}
|
}
|
||||||
#endif /* USE_ELF_CORE_DUMP */
|
#endif /* USE_ELF_CORE_DUMP */
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue