]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: airoha: Move entries to queue head in case of DMA mapping failure in airoha_dev_...
authorLorenzo Bianconi <lorenzo@kernel.org>
Wed, 29 Apr 2026 12:02:31 +0000 (14:02 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 1 May 2026 01:08:48 +0000 (18:08 -0700)
In order to respect the original descriptor order and avoid any
potential IOMMU fault or memory corruption, move pending queue entries
to the head of hw queue tx_list if the DMA mapping of current inflight
packet fails in airoha_dev_xmit routine.

Fixes: 3f47e67dff1f7 ("net: airoha: Add the capability to consume out-of-order DMA tx descriptors")
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Link: https://patch.msgid.link/20260429-airoha-xmit-unmap-error-path-v2-1-32e43b7c6d25@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/airoha/airoha_eth.c

index f8b3d53bccadbd73971f8c42fde5a04d77ca336a..d0c0c0ec8a80afbf323e46b9bfa774adf2e770a1 100644 (file)
@@ -2120,14 +2120,12 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
        return NETDEV_TX_OK;
 
 error_unmap:
-       while (!list_empty(&tx_list)) {
-               e = list_first_entry(&tx_list, struct airoha_queue_entry,
-                                    list);
+       list_for_each_entry(e, &tx_list, list) {
                dma_unmap_single(dev->dev.parent, e->dma_addr, e->dma_len,
                                 DMA_TO_DEVICE);
                e->dma_addr = 0;
-               list_move_tail(&e->list, &q->tx_list);
        }
+       list_splice(&tx_list, &q->tx_list);
 
        spin_unlock_bh(&q->lock);
 error: