usbGetDevice: don't leak a "usbDevice" buffer on failure path

* src/util/hostusb.c (usbGetDevice): Free "dev" when returning NULL.
This commit is contained in:
Jim Meyering 2010-01-25 16:44:13 +01:00
parent 9827e0a42c
commit 3dc4268669

View 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;