From: Daniel P. Berrange Date: Mon, 19 Apr 2010 13:16:46 +0000 (+0100) Subject: Fix crash in nwfilter driver check X-Git-Tag: v0.8.1~69 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98bd5e6c5a2634bcb99992dd10dd41a352ac210c;p=thirdparty%2Flibvirt.git Fix crash in nwfilter driver check 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() --- diff --git a/src/nwfilter/nwfilter_driver.c b/src/nwfilter/nwfilter_driver.c index d37ee605fd..3ded2beb14 100644 --- a/src/nwfilter/nwfilter_driver.c +++ b/src/nwfilter/nwfilter_driver.c @@ -164,9 +164,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; } /**