]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
usbGetDevice: don't leak a "usbDevice" buffer on failure path
authorJim Meyering <meyering@redhat.com>
Mon, 25 Jan 2010 15:44:13 +0000 (16:44 +0100)
committerJim Meyering <meyering@redhat.com>
Mon, 25 Jan 2010 16:07:06 +0000 (17:07 +0100)
* src/util/hostusb.c (usbGetDevice): Free "dev" when returning NULL.

src/util/hostusb.c

index 9a37103caf3a0ad76e09a28e80e4d5b7789c927d..f635ce5ebff5355353d78272412bd5f3ef9abc0c 100644 (file)
@@ -171,8 +171,10 @@ usbGetDevice(virConnectPtr conn,
 
     if (vendor) {
         /* Look up bus.dev by vendor:product */
-        if (usbFindBusByVendor(conn, vendor, product, &bus, &devno) < 0)
+        if (usbFindBusByVendor(conn, vendor, product, &bus, &devno) < 0) {
+            VIR_FREE(dev);
             return NULL;
+        }
     }
 
     dev->bus     = bus;