]> git.ipfire.org Git - thirdparty/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)
committerCole Robinson <crobinso@redhat.com>
Thu, 14 Jun 2012 22:16:48 +0000 (18:16 -0400)
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.
(cherry picked from commit ab5fb8f34c93661bb19b62e4ed3592fb53cd6b36)

src/qemu/qemu_hotplug.c

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