]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
macvtap: avoid invalid free
authorRoopa Prabhu <roprabhu@cisco.com>
Fri, 14 Oct 2011 20:41:46 +0000 (13:41 -0700)
committerEric Blake <eblake@redhat.com>
Fri, 14 Oct 2011 20:54:47 +0000 (14:54 -0600)
Commit 0472f39 plugged a leak, but introduced another bug:

Actually looks like physfndev is conditionally allocated in getPhysfnDev
Its better to modify getPhysfnDev to allocate physfndev every time.

src/util/macvtap.c

index a020c9058bb50495d1dfa26a7fc53f3dcab7ce12..7fd6eb54b9952c02c1c2b7f5e59951fd6ae98435 100644 (file)
@@ -964,7 +964,11 @@ getPhysfnDev(const char *linkdev,
          */
 
         *vf = PORT_SELF_VF;
-        *physfndev = (char *)linkdev;
+        *physfndev = strdup(linkdev);
+        if (!*physfndev) {
+            virReportOOMError();
+            rc = -1;
+        }
     }
 
     return rc;