]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc_process: Avoid passing NULL iface->iname
authorJohn Ferlan <jferlan@redhat.com>
Tue, 22 Jan 2013 22:09:26 +0000 (17:09 -0500)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 23 Jan 2013 14:02:06 +0000 (15:02 +0100)
A followon to commit id: 68dceb635 - if iface->iname is NULL, then
neither virNetDevOpenvswitchRemovePort() nor virNetDevVethDelete()
should be called.  Found by Coverity.

src/lxc/lxc_process.c

index 4ad7ba08eddbf9955365eca9dc41dd6e289af2a2..5598a86ffd22ad70d9a11c8284c25774512ce782 100644 (file)
@@ -262,13 +262,15 @@ static void virLXCProcessCleanup(virLXCDriverPtr driver,
     for (i = 0 ; i < vm->def->nnets ; i++) {
         virDomainNetDefPtr iface = vm->def->nets[i];
         vport = virDomainNetGetActualVirtPortProfile(iface);
-        if (iface->ifname)
+        if (iface->ifname) {
             ignore_value(virNetDevSetOnline(iface->ifname, false));
-        if (vport && vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
-            ignore_value(virNetDevOpenvswitchRemovePort(
-                            virDomainNetGetActualBridgeName(iface),
-                            iface->ifname));
-        ignore_value(virNetDevVethDelete(iface->ifname));
+            if (vport &&
+                vport->virtPortType == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH)
+                ignore_value(virNetDevOpenvswitchRemovePort(
+                                virDomainNetGetActualBridgeName(iface),
+                                iface->ifname));
+            ignore_value(virNetDevVethDelete(iface->ifname));
+        }
         networkReleaseActualDevice(iface);
     }