net: ag71xx: Add missing check after DMA map

[ Upstream commit 96a1e15e60 ]

The DMA map functions can fail and should be tested for errors.

Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250716095733.37452-3-fourier.thomas@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Thomas Fourier 2025-07-16 11:57:25 +02:00 committed by Greg Kroah-Hartman
parent 8ca79651e1
commit bb4ae7227e

View File

@ -1275,6 +1275,11 @@ static bool ag71xx_fill_rx_buf(struct ag71xx *ag, struct ag71xx_buf *buf,
buf->rx.rx_buf = data;
buf->rx.dma_addr = dma_map_single(&ag->pdev->dev, data, ag->rx_buf_size,
DMA_FROM_DEVICE);
if (dma_mapping_error(&ag->pdev->dev, buf->rx.dma_addr)) {
skb_free_frag(data);
buf->rx.rx_buf = NULL;
return false;
}
desc->data = (u32)buf->rx.dma_addr + offset;
return true;
}
@ -1573,6 +1578,10 @@ static netdev_tx_t ag71xx_hard_start_xmit(struct sk_buff *skb,
dma_addr = dma_map_single(&ag->pdev->dev, skb->data, skb->len,
DMA_TO_DEVICE);
if (dma_mapping_error(&ag->pdev->dev, dma_addr)) {
netif_dbg(ag, tx_err, ndev, "DMA mapping error\n");
goto err_drop;
}
i = ring->curr & ring_mask;
desc = ag71xx_ring_desc(ring, i);