From: Guannan Ren Date: Fri, 11 May 2012 06:29:15 +0000 (+0800) Subject: usb: fix crash when failing to attach a second usb device X-Git-Tag: v0.9.12~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ab5fb8f34c93661bb19b62e4ed3592fb53cd6b36;p=thirdparty%2Flibvirt.git usb: fix crash when failing to attach a second usb device when failing to attach another usb device to a domain for some reason which has one use device attached before, the libvirtd crashed. The crash is caused by null-pointer dereference error in invoking usbDeviceListSteal passed in NULL value usb variable. commit 05abd1507d66aabb6cad12eeafeb4c4d1911c585 introduces the bug. --- diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index ad31eba630..9b608162fe 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1213,7 +1213,8 @@ error: cleanup: usbDeviceListFree(list); - usbDeviceListSteal(driver->activeUsbHostdevs, usb); + if (usb) + usbDeviceListSteal(driver->activeUsbHostdevs, usb); return -1; }