From: Michal Privoznik Date: Wed, 19 Feb 2014 13:55:23 +0000 (+0100) Subject: networkRunHook: Run hook only if possible X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=83c404ff9b930e21c97ff47b8c942db17a96e94a;p=libvirt.git networkRunHook: Run hook only if possible Currently, networkRunHook() is called in networkAllocateActualDevice and friends. These functions, however, doesn't necessarily work on networks, For example, if domain's interface is defined in this fashion:
The networkAllocateActualDevice jumps directly onto 'validate' label as the interface is not type of 'network'. Hence, @network is left initialized to NULL and networkRunHook(network, ...) is called. One of the things that the hook function does is dereference @network. Soupir. Signed-off-by: Michal Privoznik --- diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index ee264b9989..a6c719df3e 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -150,6 +150,12 @@ networkRunHook(virNetworkObjPtr network, int ret = -1; if (virHookPresent(VIR_HOOK_DRIVER_NETWORK)) { + if (!network) { + VIR_DEBUG("Not running hook as @network is NULL"); + ret = 0; + goto cleanup; + } + virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); if (virNetworkDefFormatBuf(&buf, network->def, 0) < 0)