On Tue, 3 Nov 2026 at 21:54, Stefan Weil <[email protected]> wrote: > > e100_nic_realize() registers a system reset handler via > qemu_register_reset(nic_reset, s), but pci_nic_uninit() never > unregisters it. After the device is hot-unplugged, the LegacyReset > object stored in the root reset container still holds the raw pointer > to the freed EEPRO100State, so the next system reset invokes > nic_reset() on freed memory. > > Instead, define a reset phase on the device itself: assign > phases.hold in eepro100_class_init() to a wrapper around nic_reset(). > The device is already part of the resettable tree via its parent bus > (TYPE_DEVICE implements the Resettable interface), so no explicit > registration is needed, and the reset state is automatically dropped > when the device is unplugged. This follows the approach used by the > e1000, e1000e and igb emulations. > > Reported-by: Hui Peng <[email protected]> > Reported-by: MyeonghunPak <https://gitlab.com/mhun512> > Suggested-by: Peter Maydell <[email protected]> > Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4058 > Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4510 > Signed-off-by: Stefan Weil <[email protected]> > --- > > v1: > Initial fix, created and tested with AI assistance. > > v2: > Removed nic_reset() in e100_nic_realize as suggested by Peter Maydell. > > I did not replace the DO_UPCAST macro by a standard QOM cast which > was also suggested, because I think it is better to focus on the > required fix. Replacing DO_UPCAST would be worth a separate patch > (to be done later).
Ugh, you're right, this device has no QOM cast macros at all currently. It's clearly very old and in an ideal world could use a spring cleaning, but we should just fix this bug for now. Reviewed-by: Peter Maydell <[email protected]> thanks -- PMM
