[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 09/10] Fix reporting of errors in OOM injection code



From: "Daniel P. Berrange" <berrange redhat com>

When the various viralloc.c functions were changed to use the
normal error reporting code, the OOM injection code paths
were not updated to report errors.

Signed-off-by: Daniel P. Berrange <berrange redhat com>
---
 src/util/viralloc.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/util/viralloc.c b/src/util/viralloc.c
index 8008f33..27ed74a 100644
--- a/src/util/viralloc.c
+++ b/src/util/viralloc.c
@@ -132,6 +132,9 @@ int virAlloc(void *ptrptr,
 #if TEST_OOM
     if (virAllocTestFail()) {
         *(void **)ptrptr = NULL;
+        if (report)
+            virReportOOMErrorFull(domcode, filename, funcname, linenr);
+        errno = ENOMEM;
         return -1;
     }
 #endif
@@ -176,6 +179,9 @@ int virAllocN(void *ptrptr,
 #if TEST_OOM
     if (virAllocTestFail()) {
         *(void **)ptrptr = NULL;
+        if (report)
+            virReportOOMErrorFull(domcode, filename, funcname, linenr);
+        errno = ENOMEM;
         return -1;
     }
 #endif
@@ -220,8 +226,12 @@ int virReallocN(void *ptrptr,
 {
     void *tmp;
 #if TEST_OOM
-    if (virAllocTestFail())
+    if (virAllocTestFail()) {
+        if (report)
+            virReportOOMErrorFull(domcode, filename, funcname, linenr);
+        errno = ENOMEM;
         return -1;
+    }
 #endif
 
     if (xalloc_oversized(count, size)) {
@@ -529,8 +539,12 @@ int virAllocVar(void *ptrptr,
     size_t alloc_size = 0;
 
 #if TEST_OOM
-    if (virAllocTestFail())
+    if (virAllocTestFail()) {
+        if (report)
+            virReportOOMErrorFull(domcode, filename, funcname, linenr);
+        errno = ENOMEM;
         return -1;
+    }
 #endif
 
     if (VIR_ALLOC_VAR_OVERSIZED(struct_size, count, element_size)) {
-- 
1.8.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]