[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 10/18] memory-device: Fix memory pre-plug error API violations
From: |
Markus Armbruster |
Subject: |
[PATCH v2 10/18] memory-device: Fix memory pre-plug error API violations |
Date: |
Wed, 4 Dec 2019 10:36:17 +0100 |
memory_device_get_free_addr() dereferences @errp when
memory_device_check_addable() fails. That's wrong; see the big
comment in error.h. Introduced in commit 1b6d6af21b "pc-dimm: factor
out capacity and slot checks into MemoryDevice".
No caller actually passes null.
Fix anyway: splice in a local Error *err, and error_propagate().
Cc: David Hildenbrand <address@hidden>
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: David Hildenbrand <address@hidden>
---
hw/mem/memory-device.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/hw/mem/memory-device.c b/hw/mem/memory-device.c
index aef148c1d7..4bc9cf0917 100644
--- a/hw/mem/memory-device.c
+++ b/hw/mem/memory-device.c
@@ -99,6 +99,7 @@ static uint64_t memory_device_get_free_addr(MachineState *ms,
uint64_t align, uint64_t size,
Error **errp)
{
+ Error *err = NULL;
GSList *list = NULL, *item;
Range as, new = range_empty;
@@ -123,8 +124,9 @@ static uint64_t memory_device_get_free_addr(MachineState
*ms,
return 0;
}
- memory_device_check_addable(ms, size, errp);
- if (*errp) {
+ memory_device_check_addable(ms, size, &err);
+ if (err) {
+ error_propagate(errp, err);
return 0;
}
--
2.21.0
- [PATCH v2 01/18] crypto: Fix certificate file error handling crash bug, (continued)
- [PATCH v2 01/18] crypto: Fix certificate file error handling crash bug, Markus Armbruster, 2019/12/04
- [PATCH v2 07/18] hw/core: Fix fit_load_fdt() error handling violations, Markus Armbruster, 2019/12/04
- [PATCH v2 03/18] io: Fix Error usage in a comment <example>, Markus Armbruster, 2019/12/04
- [PATCH v2 18/18] tests-blockjob: Use error_free_or_abort(), Markus Armbruster, 2019/12/04
- [PATCH v2 14/18] s390x/cpumodel: Fix query-cpu-model-FOO error API violations, Markus Armbruster, 2019/12/04
- [PATCH v2 06/18] hw/acpi: Fix legacy CPU plug error API violations, Markus Armbruster, 2019/12/04
- [PATCH v2 10/18] memory-device: Fix memory pre-plug error API violations,
Markus Armbruster <=
- [PATCH v2 16/18] error: Clean up unusual names of Error * variables, Markus Armbruster, 2019/12/04
- [PATCH v2 15/18] s390x/cpumodel: Fix query-cpu-definitions error API violations, Markus Armbruster, 2019/12/04
- [PATCH v2 12/18] s390x/cpumodel: Fix feature property error API violations, Markus Armbruster, 2019/12/04
- Re: [PATCH v2 00/18] Error handling fixes, David Hildenbrand, 2019/12/04
- Re: [PATCH v2 00/18] Error handling fixes, Markus Armbruster, 2019/12/04
- Re: [PATCH v2 00/18] Error handling fixes, Cornelia Huck, 2019/12/05