Skip to content

Commit 1f038d5

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: airoha: fix error branch in airoha_dev_xmit and airoha_set_gdm_ports
Fix error case management in airoha_dev_xmit routine since we need to DMA unmap pending buffers starting from q->head. Moreover fix a typo in error case branch in airoha_set_gdm_ports routine. Fixes: 23020f0 ("net: airoha: Introduce ethernet support for EN7581 SoC") Signed-off-by: Lorenzo Bianconi <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/b628871bc8ae4861b5e2ab4db90aaf373cbb7cee.1721203880.git.lorenzo@kernel.org Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 03b54ba commit 1f038d5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/net/ethernet/mediatek/airoha_eth.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ static int airoha_set_gdm_ports(struct airoha_eth *eth, bool enable)
977977
return 0;
978978

979979
error:
980-
for (i--; i >= 0; i++)
980+
for (i--; i >= 0; i--)
981981
airoha_set_gdm_port(eth, port_list[i], false);
982982

983983
return err;
@@ -2431,9 +2431,11 @@ static netdev_tx_t airoha_dev_xmit(struct sk_buff *skb,
24312431
return NETDEV_TX_OK;
24322432

24332433
error_unmap:
2434-
for (i--; i >= 0; i++)
2435-
dma_unmap_single(dev->dev.parent, q->entry[i].dma_addr,
2436-
q->entry[i].dma_len, DMA_TO_DEVICE);
2434+
for (i--; i >= 0; i--) {
2435+
index = (q->head + i) % q->ndesc;
2436+
dma_unmap_single(dev->dev.parent, q->entry[index].dma_addr,
2437+
q->entry[index].dma_len, DMA_TO_DEVICE);
2438+
}
24372439

24382440
spin_unlock_bh(&q->lock);
24392441
error:

0 commit comments

Comments
 (0)