diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index f4bd19df64..d5075acab0 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -1236,7 +1236,7 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr, virUSBDeviceSetUsedBy(usb, drv_name, dom_name); - if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0) { + if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, &usb) < 0) { virUSBDeviceFree(usb); goto cleanup; } @@ -1406,7 +1406,7 @@ virHostdevMarkUSBDevices(virHostdevManagerPtr mgr, * from the virUSBDeviceList that passed in on success, * perform rollback on failure. */ - if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0) + if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, &usb) < 0) goto error; } @@ -1555,7 +1555,7 @@ virHostdevPrepareUSBDevices(virHostdevManagerPtr mgr, if (virHostdevFindUSBDevice(hostdev, required, &usb) < 0) goto cleanup; - if (usb && virUSBDeviceListAdd(list, usb) < 0) { + if (usb && virUSBDeviceListAdd(list, &usb) < 0) { virUSBDeviceFree(usb); goto cleanup; } diff --git a/src/util/virusb.c b/src/util/virusb.c index 2fe1bfc290..78182320ed 100644 --- a/src/util/virusb.c +++ b/src/util/virusb.c @@ -181,7 +181,7 @@ virUSBDeviceSearch(unsigned int vendor, if (!usb) goto cleanup; - if (virUSBDeviceListAdd(list, usb) < 0) { + if (virUSBDeviceListAdd(list, &usb) < 0) { virUSBDeviceFree(usb); goto cleanup; } @@ -463,15 +463,15 @@ virUSBDeviceListDispose(void *obj) int virUSBDeviceListAdd(virUSBDeviceListPtr list, - virUSBDevicePtr dev) + virUSBDevicePtr *dev) { - if (virUSBDeviceListFind(list, dev)) { + if (virUSBDeviceListFind(list, *dev)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Device %s is already in use"), - dev->name); + (*dev)->name); return -1; } - return VIR_APPEND_ELEMENT(list->devs, list->count, dev); + return VIR_APPEND_ELEMENT(list->devs, list->count, *dev); } virUSBDevicePtr diff --git a/src/util/virusb.h b/src/util/virusb.h index 716e8c6915..078dee69cd 100644 --- a/src/util/virusb.h +++ b/src/util/virusb.h @@ -88,7 +88,7 @@ int virUSBDeviceFileIterate(virUSBDevicePtr dev, virUSBDeviceListPtr virUSBDeviceListNew(void); int virUSBDeviceListAdd(virUSBDeviceListPtr list, - virUSBDevicePtr dev); + virUSBDevicePtr *dev); virUSBDevicePtr virUSBDeviceListGet(virUSBDeviceListPtr list, int idx); size_t virUSBDeviceListCount(virUSBDeviceListPtr list); diff --git a/tests/virusbtest.c b/tests/virusbtest.c index 8728fe9092..05bba2b9ba 100644 --- a/tests/virusbtest.c +++ b/tests/virusbtest.c @@ -173,7 +173,7 @@ testUSBList(const void *opaque ATTRIBUTE_UNUSED) dev = virUSBDeviceListGet(devlist, 0); dev = virUSBDeviceListSteal(devlist, dev); - if (virUSBDeviceListAdd(list, dev) < 0) + if (virUSBDeviceListAdd(list, &dev) < 0) goto cleanup; dev = NULL; } @@ -196,7 +196,7 @@ testUSBList(const void *opaque ATTRIBUTE_UNUSED) dev = virUSBDeviceListGet(devlist, 0); dev = virUSBDeviceListSteal(devlist, dev); - if (virUSBDeviceListAdd(list, dev) < 0) + if (virUSBDeviceListAdd(list, &dev) < 0) goto cleanup; dev = NULL; }