mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-30 01:43:23 +00:00
nwfilter: don't crash listing filters in unprivileged daemon
The unprivileged libvirtd does not support nwfilter config, by leaves the driver active. It is supposed to result in all APIs being an effective no-op, but several APIs rely on driver->nwfilters being non-NULL, or they will reference a NULL pointer. Rather than adding checks for NULL in many places, just make sure driver->nwfilters is always initialized. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
ab7a2fe230
commit
7993554f70
@ -189,6 +189,8 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
/* remember that we are going to use firewalld */
|
/* remember that we are going to use firewalld */
|
||||||
driver->watchingFirewallD = (sysbus != NULL);
|
driver->watchingFirewallD = (sysbus != NULL);
|
||||||
driver->privileged = privileged;
|
driver->privileged = privileged;
|
||||||
|
if (!(driver->nwfilters = virNWFilterObjListNew()))
|
||||||
|
goto error;
|
||||||
|
|
||||||
if (!privileged)
|
if (!privileged)
|
||||||
return 0;
|
return 0;
|
||||||
@ -244,9 +246,6 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(driver->nwfilters = virNWFilterObjListNew()))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (virNWFilterObjListLoadAllConfigs(driver->nwfilters, driver->configDir) < 0)
|
if (virNWFilterObjListLoadAllConfigs(driver->nwfilters, driver->configDir) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
@ -271,6 +270,7 @@ nwfilterStateInitialize(bool privileged,
|
|||||||
virNWFilterIPAddrMapShutdown();
|
virNWFilterIPAddrMapShutdown();
|
||||||
|
|
||||||
err_free_driverstate:
|
err_free_driverstate:
|
||||||
|
virNWFilterObjListFree(driver->nwfilters);
|
||||||
VIR_FREE(driver);
|
VIR_FREE(driver);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
@ -349,13 +349,13 @@ nwfilterStateCleanup(void)
|
|||||||
|
|
||||||
nwfilterDriverRemoveDBusMatches();
|
nwfilterDriverRemoveDBusMatches();
|
||||||
|
|
||||||
/* free inactive nwfilters */
|
|
||||||
virNWFilterObjListFree(driver->nwfilters);
|
|
||||||
|
|
||||||
VIR_FREE(driver->configDir);
|
VIR_FREE(driver->configDir);
|
||||||
nwfilterDriverUnlock();
|
nwfilterDriverUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* free inactive nwfilters */
|
||||||
|
virNWFilterObjListFree(driver->nwfilters);
|
||||||
|
|
||||||
virMutexDestroy(&driver->lock);
|
virMutexDestroy(&driver->lock);
|
||||||
VIR_FREE(driver);
|
VIR_FREE(driver);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user