From: Cole Robinson Date: Thu, 5 Dec 2013 20:03:00 +0000 (-0500) Subject: qemu: hotplug: Fix double free on USB collision X-Git-Tag: CVE-2013-6436~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5953a73787b50da56e2ee820a8095ccb09c7a79b;p=thirdparty%2Flibvirt.git qemu: hotplug: Fix double free on USB collision If we hit a collision, we free the USB device while it is still part of our temporary USBDeviceList. When the list is unref'd, the device is free'd again. Make the initial device freeing dependent on whether it is present in the temporary list or not. --- diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index bff9e23df5..b7512a71dc 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1518,7 +1518,10 @@ cleanup: } if (added) virUSBDeviceListSteal(driver->activeUsbHostdevs, usb); - virUSBDeviceFree(usb); + if (list && usb && + !virUSBDeviceListFind(list, usb) && + !virUSBDeviceListFind(driver->activeUsbHostdevs, usb)) + virUSBDeviceFree(usb); virObjectUnref(list); VIR_FREE(devstr); return ret;