hw/usb/hcd-ehci: Fix crash when showing help of EHCI devices
commitdb0b034185824ac33e1a85ba62ab2030eb17b00d
authorThomas Huth <thuth@redhat.com>
Fri, 26 Mar 2021 09:51:55 +0000 (26 10:51 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 26 Mar 2021 10:10:49 +0000 (26 11:10 +0100)
tree9664b24bf16b65228bccd9a6d909fc8d8a1ffeaf
parentadcf33a504de29feb720736051dc32889314c9e6
hw/usb/hcd-ehci: Fix crash when showing help of EHCI devices

QEMU crashes with certain targets when trying to show the help
output of EHCI devices:

$ ./qemu-system-aarch64 -device ich9-usb-ehci1,help
qemu-system-aarch64: ../../devel/qemu/softmmu/physmem.c:1154: phys_section_add:
 Assertion `map->sections_nb < TARGET_PAGE_SIZE' failed.
Aborted (core dumped)

This happens because the device is doing things at "instance_init" time
that should be done at "realize" time instead. So move the related code
to the realize() function instead. (NB: This now also matches the
memory_region_del_subregion() calls which are done in usb_ehci_unrealize(),
and not during finalize()).

Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20210326095155.1994604-1-thuth@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb/hcd-ehci.c