]> xenbits.xensource.com Git - libvirt.git/commitdiff
hotplug: Resolve Coverity FORWARD_NULL
authorJohn Ferlan <jferlan@redhat.com>
Tue, 30 Sep 2014 10:55:23 +0000 (06:55 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Mon, 1 Dec 2014 16:07:31 +0000 (11:07 -0500)
Coverity complained that because the cfg->macFilter call checked
net->ifname != NULL before calling ebtablesRemoveForwardAllowIn, then
the virNetDevOpenvswitchRemovePort call should have the same check.

However, if I move the ebtables call prior to the check for TYPE_DIRECT
(where there is a VIR_FREE(net->ifname)), then it seems Coverity is
happy.  Since firewall info is tacked on last during setup, removing
it in the opposite order of initialization seems to be natural anyway

src/qemu/qemu_hotplug.c

index f2740f46f34a568ea6db4dc97f256f2b15e3957d..ff0eaf8016df8d22cb7f0451a6b09d5b820a7234 100644 (file)
@@ -2786,6 +2786,12 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
     qemuDomainReleaseDeviceAddress(vm, &net->info, NULL);
     virDomainConfNWFilterTeardown(net);
 
+    if (cfg->macFilter && (net->ifname != NULL)) {
+        ignore_value(ebtablesRemoveForwardAllowIn(driver->ebtables,
+                                                  net->ifname,
+                                                  &net->mac));
+    }
+
     if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_DIRECT) {
         ignore_value(virNetDevMacVLanDeleteWithVPortProfile(
                          net->ifname, &net->mac,
@@ -2796,12 +2802,6 @@ qemuDomainRemoveNetDevice(virQEMUDriverPtr driver,
         VIR_FREE(net->ifname);
     }
 
-    if (cfg->macFilter && (net->ifname != NULL)) {
-        ignore_value(ebtablesRemoveForwardAllowIn(driver->ebtables,
-                                                  net->ifname,
-                                                  &net->mac));
-    }
-
     vport = virDomainNetGetActualVirtPortProfile(net);
     if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
         ignore_value(virNetDevOpenvswitchRemovePort(