[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 25/29] exec: fix error handling in file_ram_alloc
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 25/29] exec: fix error handling in file_ram_alloc |
Date: |
Tue, 22 Mar 2016 15:17:05 +0100 |
One instance of double closing, and invalid close(-1) in some cases
of "goto error".
Reviewed-by: Laszlo Ersek <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
exec.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/exec.c b/exec.c
index be2a644..f46e596 100644
--- a/exec.c
+++ b/exec.c
@@ -1239,7 +1239,7 @@ static void *file_ram_alloc(RAMBlock *block,
char *sanitized_name;
char *c;
void *area;
- int fd;
+ int fd = -1;
int64_t page_size;
if (kvm_enabled() && !kvm_has_sync_mmu()) {
@@ -1321,7 +1321,6 @@ static void *file_ram_alloc(RAMBlock *block,
if (area == MAP_FAILED) {
error_setg_errno(errp, errno,
"unable to map backing store for guest RAM");
- close(fd);
goto error;
}
@@ -1336,7 +1335,9 @@ error:
if (unlink_on_error) {
unlink(path);
}
- close(fd);
+ if (fd != -1) {
+ close(fd);
+ }
return NULL;
}
#endif
--
2.5.0
- [Qemu-devel] [PULL 16/29] tcg: pass down TranslationBlock to tcg_code_gen, (continued)
- [Qemu-devel] [PULL 16/29] tcg: pass down TranslationBlock to tcg_code_gen, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 21/29] qemu-log: dfilter-ise exec, out_asm, op and opt_op, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 18/29] qemu-log: Avoid function call for disabled qemu_log_mask logging, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 20/29] qemu-log: new option -dfilter to limit output, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 19/29] qemu-log: Improve the "exec" TB execution logging, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 17/29] qemu-log: correct help text for -d cpu, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 23/29] qemu-log: support simple pid substitution for logs, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 22/29] target-arm: dfilter support for in_asm, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 26/29] char: translate from QIOChannel error to errno, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 15/29] util: move declarations out of qemu-common.h, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 25/29] exec: fix error handling in file_ram_alloc,
Paolo Bonzini <=
- [Qemu-devel] [PULL 24/29] cputlb: modernise the debug support, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 28/29] config.status: Pass extra parameters, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 29/29] target-i386: implement PKE for TCG, Paolo Bonzini, 2016/03/22
- [Qemu-devel] [PULL 27/29] char: ensure all clients are in non-blocking mode, Paolo Bonzini, 2016/03/22
- Re: [Qemu-devel] [PULL 00/29] Miscellaneous changes for 2016-03-22, Peter Maydell, 2016/03/22