[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 06/35] exec: Fix file_ram_alloc() error API violations
From: |
Markus Armbruster |
Subject: |
[PULL v2 06/35] exec: Fix file_ram_alloc() error API violations |
Date: |
Wed, 18 Dec 2019 09:16:52 +0100 |
When os_mem_prealloc() fails, file_ram_alloc() calls qemu_ram_munmap()
and returns null. Except it doesn't when its @errp argument is null,
because it checks for failure with (errp && *errp). Introduced in
commit 056b68af77 "fix qemu exit on memory hotplug when allocation
fails at prealloc time".
No caller actually passes null.
Fix anyway: splice in a local Error *err, and error_propagate().
Cc: Igor Mammedov <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Igor Mammedov <address@hidden>
Message-Id: <address@hidden>
Reviewed-by: Philippe Mathieu-Daudé <address@hidden>
---
exec.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/exec.c b/exec.c
index a34c348184..6bd4aa1d87 100644
--- a/exec.c
+++ b/exec.c
@@ -1843,6 +1843,7 @@ static void *file_ram_alloc(RAMBlock *block,
bool truncate,
Error **errp)
{
+ Error *err = NULL;
MachineState *ms = MACHINE(qdev_get_machine());
void *area;
@@ -1900,8 +1901,9 @@ static void *file_ram_alloc(RAMBlock *block,
}
if (mem_prealloc) {
- os_mem_prealloc(fd, area, memory, ms->smp.cpus, errp);
- if (errp && *errp) {
+ os_mem_prealloc(fd, area, memory, ms->smp.cpus, &err);
+ if (err) {
+ error_propagate(errp, err);
qemu_ram_munmap(fd, area, memory);
return NULL;
}
--
2.21.0
- [PULL v2 00/35] Error reporting patches for 2019-12-17, Markus Armbruster, 2019/12/18
- [PULL v2 01/35] error: Fix -msg timestamp default, Markus Armbruster, 2019/12/18
- [PULL v2 02/35] crypto: Fix certificate file error handling crash bug, Markus Armbruster, 2019/12/18
- [PULL v2 18/35] vnc: drop Error pointer indirection in vnc_client_io_error, Markus Armbruster, 2019/12/18
- [PULL v2 20/35] Revert "ppc: well form kvmppc_hint_smt_possible error hint helper", Markus Armbruster, 2019/12/18
- [PULL v2 14/35] tests-blockjob: Use error_free_or_abort(), Markus Armbruster, 2019/12/18
- [PULL v2 07/35] hw/acpi: Fix legacy CPU plug error API violations, Markus Armbruster, 2019/12/18
- [PULL v2 06/35] exec: Fix file_ram_alloc() error API violations,
Markus Armbruster <=
- [PULL v2 05/35] tests: Clean up initialization of Error *err variables, Markus Armbruster, 2019/12/18
- [PULL v2 10/35] qga: Fix guest-get-fsinfo error API violations, Markus Armbruster, 2019/12/18
- [PULL v2 21/35] ppc: make Error **errp const where it is appropriate, Markus Armbruster, 2019/12/18
- [PULL v2 11/35] memory-device: Fix memory pre-plug error API violations, Markus Armbruster, 2019/12/18
- [PULL v2 25/35] hw/i386/amd_iommu: rename Error ** parameter to more common errp, Markus Armbruster, 2019/12/18
- [PULL v2 19/35] qdev-monitor: make Error **errp const where it is appropriate, Markus Armbruster, 2019/12/18
- [PULL v2 22/35] 9pfs: make Error **errp const where it is appropriate, Markus Armbruster, 2019/12/18
- [PULL v2 13/35] hw/intc/s390: Simplify error handling in kvm_s390_flic_realize(), Markus Armbruster, 2019/12/18
- [PULL v2 30/35] hw/tpm: rename Error ** parameter to more common errp, Markus Armbruster, 2019/12/18
- [PULL v2 27/35] monitor/qmp-cmds: rename Error ** parameter to more common errp, Markus Armbruster, 2019/12/18