uhci: fix segfault when hot-unplugging uhci controller
commit537e572a7f807d7371a73ea5ffd9ce8d2487ff0c
authorGonglei <arei.gonglei@huawei.com>
Wed, 18 Mar 2015 09:33:46 +0000 (18 17:33 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 20 Mar 2015 07:50:01 +0000 (20 08:50 +0100)
tree9adc39094a372c025a81df49998cbfa3794c6dc1
parent8ffd9f4dd41f0423f0df8bef8f2e25ab4bb1a3f3
uhci: fix segfault when hot-unplugging uhci controller

When hot-unplugging the usb controllers (ehci/uhci),
we have to clean all resouce of these devices,
involved registered reset handler. Otherwise, it
may cause NULL pointer access and/or segmentation fault
if we reboot the guest os after hot-unplugging.

Let's hook up reset via DeviceClass->reset() and drop
the qemu_register_reset() call. Then Qemu will register
and unregister the reset handler automatically.

Cc: qemu-stable <qemu-stable@nongnu.org>
Reported-by: Lidonglin <lidonglin@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/hcd-uhci.c