[libvirt] [PATCH] Fix crash in nwfilter driver check

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

 



The nwfilterDriverActive() could de-reference a NULL pointer
if it hadn't be started at the point it was called. It was
also not thread safe, since it lacked locking around data
accesses.

* src/nwfilter/nwfilter_driver.c: Fix locking & NULL checks
  in nwfilterDriverActive()
---
 src/nwfilter/nwfilter_driver.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c
index 58df4e1..412c5b8 100644
--- a/src/nwfilter/nwfilter_driver.c
+++ b/src/nwfilter/nwfilter_driver.c
@@ -153,9 +153,16 @@ nwfilterDriverReload(void) {
  */
 static int
 nwfilterDriverActive(void) {
-    if (!driverState->pools.count)
+    int ret;
+
+    if (!driverState)
         return 0;
-    return 1;
+
+    nwfilterDriverLock(driverState);
+    ret = driverState->pools.count ? 1 : 0;
+    nwfilterDriverUnlock(driverState);
+
+    return ret;
 }
 
 /**
-- 
1.6.6.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]