[Qemu-devel] [PATCH v3 1/3] uhci: fix segfault when hot-unplugging uhci controller

2015-03-17 Thread arei.gonglei
From: Gonglei 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 Devic

Re: [Qemu-devel] [PATCH v3 1/3] uhci: fix segfault when hot-unplugging uhci controller

2015-03-18 Thread Gerd Hoffmann
Hi, > -static void uhci_reset(void *opaque) > +static void uhci_reset(DeviceState *dev) > { > -UHCIState *s = opaque; > +PCIDevice *d = PCI_DEVICE(dev); > +UHCIState *s = DO_UPCAST(UHCIState, dev, d); Uh, oh, DO_UPCAST() is long deprecated. There are other instances of this in the

Re: [Qemu-devel] [PATCH v3 1/3] uhci: fix segfault when hot-unplugging uhci controller

2015-03-18 Thread Gonglei
On 2015/3/18 15:02, Gerd Hoffmann wrote: > Hi, > >> -static void uhci_reset(void *opaque) >> +static void uhci_reset(DeviceState *dev) >> { >> -UHCIState *s = opaque; >> +PCIDevice *d = PCI_DEVICE(dev); >> +UHCIState *s = DO_UPCAST(UHCIState, dev, d); > > Uh, oh, DO_UPCAST() is lon

Re: [Qemu-devel] [PATCH v3 1/3] uhci: fix segfault when hot-unplugging uhci controller

2015-03-18 Thread Markus Armbruster
Gerd Hoffmann writes: > Hi, > >> -static void uhci_reset(void *opaque) >> +static void uhci_reset(DeviceState *dev) >> { >> -UHCIState *s = opaque; >> +PCIDevice *d = PCI_DEVICE(dev); >> +UHCIState *s = DO_UPCAST(UHCIState, dev, d); > > Uh, oh, DO_UPCAST() is long deprecated. Ther

Re: [Qemu-devel] [PATCH v3 1/3] uhci: fix segfault when hot-unplugging uhci controller

2015-03-18 Thread Gonglei
On 2015/3/18 15:35, Markus Armbruster wrote: > Gerd Hoffmann writes: > >> Hi, >> >>> -static void uhci_reset(void *opaque) >>> +static void uhci_reset(DeviceState *dev) >>> { >>> -UHCIState *s = opaque; >>> +PCIDevice *d = PCI_DEVICE(dev); >>> +UHCIState *s = DO_UPCAST(UHCIState, d