Commit 96a1e15e authored by Thomas Fourier's avatar Thomas Fourier Committed by Jakub Kicinski
Browse files

net: ag71xx: Add missing check after DMA map



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

Signed-off-by: default avatarThomas Fourier <fourier.thomas@gmail.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250716095733.37452-3-fourier.thomas@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent b6645645
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -1213,6 +1213,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;
}
@@ -1511,6 +1516,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);