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.
(cherry picked from commit ab5fb8f34c93661bb19b62e4ed3592fb53cd6b36)
This commit is contained in:
Guannan Ren 2012-05-11 14:29:15 +08:00 committed by Cole Robinson
parent d1186c589f
commit 48b9eb2d55

View File

@ -1213,7 +1213,8 @@ error:
cleanup:
usbDeviceListFree(list);
usbDeviceListSteal(driver->activeUsbHostdevs, usb);
if (usb)
usbDeviceListSteal(driver->activeUsbHostdevs, usb);
return -1;
}