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()
This commit is contained in:
Daniel P. Berrange 2010-04-19 14:16:46 +01:00
parent 3022375da3
commit 98bd5e6c5a

View File

@ -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;
}
/**