linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] net: ag71xx: Add missing check after DMA map
@ 2025-07-16  9:57 Thomas Fourier
  2025-07-16 18:43 ` Simon Horman
  2025-07-18  2:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Fourier @ 2025-07-16  9:57 UTC (permalink / raw)
  Cc: Thomas Fourier, Chris Snook, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Oleksij Rempel, netdev,
	linux-kernel

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

Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
v1 -> v2:
  - do not pass free function to ag71xx_fill_rx_buf()

 drivers/net/ethernet/atheros/ag71xx.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c
index d8e6f23e1432..cbc730c7cff2 100644
--- a/drivers/net/ethernet/atheros/ag71xx.c
+++ b/drivers/net/ethernet/atheros/ag71xx.c
@@ -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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: ag71xx: Add missing check after DMA map
  2025-07-16  9:57 [PATCH net v2] net: ag71xx: Add missing check after DMA map Thomas Fourier
@ 2025-07-16 18:43 ` Simon Horman
  2025-07-18  2:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2025-07-16 18:43 UTC (permalink / raw)
  To: Thomas Fourier
  Cc: Chris Snook, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Oleksij Rempel, netdev, linux-kernel

On Wed, Jul 16, 2025 at 11:57:25AM +0200, Thomas Fourier wrote:
> The DMA map functions can fail and should be tested for errors.
> 
> Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
> v1 -> v2:
>   - do not pass free function to ag71xx_fill_rx_buf()

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] net: ag71xx: Add missing check after DMA map
  2025-07-16  9:57 [PATCH net v2] net: ag71xx: Add missing check after DMA map Thomas Fourier
  2025-07-16 18:43 ` Simon Horman
@ 2025-07-18  2:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-07-18  2:10 UTC (permalink / raw)
  To: Thomas Fourier
  Cc: chris.snook, andrew+netdev, davem, edumazet, kuba, pabeni,
	o.rempel, netdev, linux-kernel

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed, 16 Jul 2025 11:57:25 +0200 you wrote:
> The DMA map functions can fail and should be tested for errors.
> 
> Fixes: d51b6ce441d3 ("net: ethernet: add ag71xx driver")
> Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
> ---
> v1 -> v2:
>   - do not pass free function to ag71xx_fill_rx_buf()
> 
> [...]

Here is the summary with links:
  - [net,v2] net: ag71xx: Add missing check after DMA map
    https://git.kernel.org/netdev/net-next/c/96a1e15e6021

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-07-18  2:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16  9:57 [PATCH net v2] net: ag71xx: Add missing check after DMA map Thomas Fourier
2025-07-16 18:43 ` Simon Horman
2025-07-18  2:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).