]> www.infradead.org Git - users/dwmw2/qemu.git/commit
net: do not delete nics in net_cleanup()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 17 Oct 2023 20:59:03 +0000 (21:59 +0100)
committerDavid Woodhouse <dwmw@amazon.co.uk>
Thu, 19 Oct 2023 08:14:38 +0000 (09:14 +0100)
commit05096ec106ccacf8f68a6a302869e331adc64f66
tree989f453d6aa89b6c859cf59b3060f951f9a029e4
parent0911264c856acc8fdc69c5a98b8c73d6bc272563
net: do not delete nics in net_cleanup()

In net_cleanup() we only need to delete the netdevs, as those may have
state which outlives Qemu when it exits, and thus may actually need to
be cleaned up on exit.

The nics, on the other hand, are owned by the device which created them.
Most devices don't bother to clean up on exit because they don't have
any state which will outlive Qemu... but XenBus devices do need to clean
up their nodes in XenStore, and do have an exit handler to delete them.

When the XenBus exit handler destroys the xen-net-device, it attempts
to delete its nic after net_cleanup() had already done so. And crashes.

Fix this by only deleting netdevs as we walk the list. As the comment
notes, we can't use QTAILQ_FOREACH_SAFE() as each deletion may remove
*multiple* entries, including the "safely" saved 'next' pointer. But
we can store the *previous* entry, since nics are safe.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
net/net.c