[virtio] Fix assertion failures when interface is closed

The unused RX I/O buffers are currently freed without being deleted
from the list, with the list head being reinitialised only after all
buffers have been deleted.  This triggers assertion failures due to
the list integrity checks when debugging is enabled.

Fix by deleting each buffer individually, so that the list structure
remains valid at all times.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2026-04-23 14:57:20 +01:00
parent 2b2580f78f
commit 1c54e7e8a4

View File

@ -338,10 +338,11 @@ static void virtnet_close ( struct net_device *netdev ) {
virtnet_free_virtqueues ( netdev );
/* Free rx iobufs */
list_for_each_entry_safe ( iobuf, next_iobuf, &virtnet->rx_iobufs, list ) {
list_for_each_entry_safe ( iobuf, next_iobuf, &virtnet->rx_iobufs,
list ) {
list_del ( &iobuf->list );
free_rx_iob ( iobuf );
}
INIT_LIST_HEAD ( &virtnet->rx_iobufs );
virtnet->rx_num_iobufs = 0;
}