Skip to contentSkip to conversation

numa: handle mmaped memory allocation failure correctly

PATCH In review Igor Mammedov 2 participants 2 messages Jun 17, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 numa: handle mmaped memory allocation failure correctly

when memory_region_init_ram_from_file() fails memory_region_size() will still return size that was provided at region init time.
Instead use errp to properly detect error condition.

---
patch depends on current PCI tree that stages last NUMA series

 numa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
numa.c +1 -1
index eef0717..e471afe 100644
@@ -238,7 +238,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
         /* Legacy behavior: if allocation failed, fall back to
          * regular RAM allocation.
          */
-        if (!memory_region_size(mr)) {
+        if (err) {
             qerror_report_err(err);
             error_free(err);
             memory_region_init_ram(mr, owner, name, ram_size);
Signature · 1 line
1.7.1
#1 lore raw
Quoted 6 lines · Igor Mammedov

when memory_region_init_ram_from_file() fails memory_region_size() will still return size that was provided at region init time.
Instead use errp to properly detect error condition.

Obviously correct, applied.
Thanks!

Quoted 21 lines

---
patch depends on current PCI tree that stages last NUMA series

 numa.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
numa.c +1 -1
index eef0717..e471afe 100644
@@ -238,7 +238,7 @@ static void allocate_system_memory_nonnuma(MemoryRegion *mr, Object *owner,
         /* Legacy behavior: if allocation failed, fall back to
          * regular RAM allocation.
          */
-        if (!memory_region_size(mr)) {
+        if (err) {
             qerror_report_err(err);
             error_free(err);
             memory_region_init_ram(mr, owner, name, ram_size);
Signature · 1 line
1.7.1