public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: ethernet: nixge: Add missing check after DMA map
@ 2025-07-25 13:33 Thomas Fourier
  2025-07-25 13:53 ` Eric Dumazet
  0 siblings, 1 reply; 5+ messages in thread
From: Thomas Fourier @ 2025-07-25 13:33 UTC (permalink / raw)
  Cc: Thomas Fourier, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Uwe Kleine-König,
	Moritz Fischer, netdev, linux-kernel

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

Fixes: 492caffa8a1a ("net: ethernet: nixge: Add support for National Instruments XGE netdev")
Signed-off-by: Thomas Fourier <fourier.thomas@gmail.com>
---
 drivers/net/ethernet/ni/nixge.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index 230d5ff99dd7..027e53023007 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -334,6 +334,10 @@ static int nixge_hw_dma_bd_init(struct net_device *ndev)
 		phys = dma_map_single(ndev->dev.parent, skb->data,
 				      NIXGE_MAX_JUMBO_FRAME_SIZE,
 				      DMA_FROM_DEVICE);
+		if (dma_mapping_error(ndev->dev.parent, phys)) {
+			dev_kfree_skb_any(skb);
+			goto out;
+		}
 
 		nixge_hw_dma_bd_set_phys(&priv->rx_bd_v[i], phys);
 
@@ -645,8 +649,8 @@ static int nixge_recv(struct net_device *ndev, int budget)
 					  NIXGE_MAX_JUMBO_FRAME_SIZE,
 					  DMA_FROM_DEVICE);
 		if (dma_mapping_error(ndev->dev.parent, cur_phys)) {
-			/* FIXME: bail out and clean up */
-			netdev_err(ndev, "Failed to map ...\n");
+			dev_kfree_skb_any(new_skb);
+			return packets;
 		}
 		nixge_hw_dma_bd_set_phys(cur_p, cur_phys);
 		cur_p->cntrl = NIXGE_MAX_JUMBO_FRAME_SIZE;
-- 
2.43.0


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

end of thread, other threads:[~2025-07-28 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-25 13:33 [PATCH net] net: ethernet: nixge: Add missing check after DMA map Thomas Fourier
2025-07-25 13:53 ` Eric Dumazet
2025-07-25 15:10   ` Jakub Kicinski
2025-07-25 15:47     ` Eric Dumazet
2025-07-28 13:56     ` Thomas Fourier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox