From 83c404ff9b930e21c97ff47b8c942db17a96e94a Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Wed, 19 Feb 2014 14:55:23 +0100 Subject: [PATCH] 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 --- src/network/bridge_driver.c | 6 ++++++ 1 file changed, 6 insertions(+) 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) -- GitLab