On 11/4/26 00:54, Stefan Weil via qemu development 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]>
---
hw/net/eepro100.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
I'm picking this one up for qemu-stable too. It's not a big deal
since the situation is quite obscure and the emulated nic is rather
obsolete by now, it's unlikely someone will try to hot-unplug it.
But qemu should not crash in such cases, and the change is simple
enough.
Thanks,
/mjt