[libvirt] [PATCH] nwfilter: report an error on OOM

Ján Tomko jtomko at redhat.com
Fri Nov 30 14:07:50 UTC 2012


Also removed some unreachable code found by coverity:
libvirt-0.10.2/src/nwfilter/nwfilter_driver.c:259: unreachable: This
code cannot be reached: "nwfilterDriverUnlock(driver...".
---
diff to v1: don't break everything

 src/nwfilter/nwfilter_driver.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index a0ee4f1..cff384e 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -174,8 +174,10 @@ nwfilterDriverStartup(bool privileged)
     sysbus = virDBusGetSystemBus();
 #endif /* HAVE_DBUS */
 
-    if (VIR_ALLOC(driverState) < 0)
-        goto alloc_err_exit;
+    if (VIR_ALLOC(driverState) < 0) {
+        virReportOOMError();
+        return -1;
+    }
 
     if (virMutexInit(&driverState->lock) < 0)
         goto err_free_driverstate;
@@ -247,11 +249,8 @@ error:
     nwfilterDriverUnlock(driverState);
     nwfilterDriverShutdown();
 
-alloc_err_exit:
     return -1;
 
-    nwfilterDriverUnlock(driverState);
-
 err_techdrivers_shutdown:
     virNWFilterTechDriversShutdown();
     virNWFilterDHCPSnoopShutdown();
-- 
1.7.8.6




More information about the libvir-list mailing list