Remove extraneous check for 'netdef' when dereferencing for vlan.nTags. Prior code would already check if netdef was NULL. Coverity complained about a path where the 'vlan' was potentially valid, but a prior checks may not have allocated 'iface->data.network.actual', so like other paths it needs to be allocated on the fly. --- src/network/bridge_driver.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index f1be954..e2b8d06 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -4005,11 +4005,21 @@ networkAllocateActualDevice(virDomainNetDefPtr iface) vlan = &iface->vlan; else if (portgroup && portgroup->vlan.nTags > 0) vlan = &portgroup->vlan; - else if (netdef && netdef->vlan.nTags > 0) + else if (netdef->vlan.nTags > 0) vlan = &netdef->vlan; - if (virNetDevVlanCopy(&iface->data.network.actual->vlan, vlan) < 0) - goto error; + if (vlan) { + /* data.network.actual may be NULL here when netdef->foward.type is + * VIR_NETWORK_FORWARD_{NONE|NAT|ROUTE} + */ + if (!iface->data.network.actual + && (VIR_ALLOC(iface->data.network.actual) < 0)) { + virReportOOMError(); + goto error; + } + if (virNetDevVlanCopy(&iface->data.network.actual->vlan, vlan) < 0) + goto error; + } validate: /* make sure that everything now specified for the device is -- 1.7.11.7 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list