From: Michael Brown Date: Thu, 16 Oct 2025 15:31:03 +0000 (+0100) Subject: [ena] Cancel uncompleted transmit buffers on close X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5e371f485bfd10c45a96859aa4aaf91007d570b;p=thirdparty%2Fipxe.git [ena] Cancel uncompleted transmit buffers on close Avoid spurious assertion failures by ensuring that references to uncompleted transmit buffers are not retained after the device has been closed. Signed-off-by: Michael Brown --- diff --git a/src/drivers/net/ena.c b/src/drivers/net/ena.c index 51375e47f..c6b08acbe 100644 --- a/src/drivers/net/ena.c +++ b/src/drivers/net/ena.c @@ -859,12 +859,32 @@ static void ena_refill_rx ( struct net_device *netdev ) { * @v ena ENA device */ static void ena_empty_rx ( struct ena_nic *ena ) { + struct io_buffer *iobuf; unsigned int i; for ( i = 0 ; i < ENA_RX_COUNT ; i++ ) { - if ( ena->rx_iobuf[i] ) - free_iob ( ena->rx_iobuf[i] ); + iobuf = ena->rx_iobuf[i]; ena->rx_iobuf[i] = NULL; + if ( iobuf ) + free_iob ( iobuf ); + } +} + +/** + * Cancel uncompleted transmit I/O buffers + * + * @v netdev Network device + */ +static void ena_cancel_tx ( struct net_device *netdev ) { + struct ena_nic *ena = netdev->priv; + struct io_buffer *iobuf; + unsigned int i; + + for ( i = 0 ; i < ENA_TX_COUNT ; i++ ) { + iobuf = ena->tx_iobuf[i]; + ena->tx_iobuf[i] = NULL; + if ( iobuf ) + netdev_tx_complete_err ( netdev, iobuf, -ECANCELED ); } } @@ -917,6 +937,9 @@ static void ena_close ( struct net_device *netdev ) { /* Destroy transmit queue pair */ ena_destroy_qp ( ena, &ena->tx ); + + /* Cancel any uncompleted transmit buffers */ + ena_cancel_tx ( netdev ); } /**