]> xenbits.xensource.com Git - libvirt.git/commitdiff
usb: fix crash when failing to attach a second usb device
authorGuannan Ren <gren@redhat.com>
Fri, 11 May 2012 06:29:15 +0000 (14:29 +0800)
committerGuannan Ren <gren@redhat.com>
Fri, 11 May 2012 06:29:15 +0000 (14:29 +0800)
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.

src/qemu/qemu_hotplug.c

index ad31eba63093dd63754729be54a064050786b5f4..9b608162fecee3074b1de8afe4e9c6539605fed2 100644 (file)
@@ -1213,7 +1213,8 @@ error:
 
 cleanup:
     usbDeviceListFree(list);
-    usbDeviceListSteal(driver->activeUsbHostdevs, usb);
+    if (usb)
+        usbDeviceListSteal(driver->activeUsbHostdevs, usb);
     return -1;
 }