public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: broadcom: b44: Add missing dma_mapping_error in b44_start_xmit
@ 2026-03-23 18:09 Adriano Vero
  2026-03-23 21:23 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Adriano Vero @ 2026-03-23 18:09 UTC (permalink / raw)
  To: michael.chan; +Cc: davem, kuba, edumazet, pabeni, netdev, Adriano Vero

The b44 driver calls dma_map_single() in the transmit path but fails to
check the return value for errors using dma_mapping_error(). If the DMA
mapping fails under memory pressure, it can lead to memory corruption.

Add the missing check, drop the skb, and return NETDEV_TX_OK to prevent
ring corruption.

Signed-off-by: Adriano Vero <litaliano00.contact@gmail.com>
---
 drivers/net/ethernet/broadcom/b44.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index 90df02e00..280ea6dbe 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -964,8 +964,14 @@ static netdev_tx_t b44_start_xmit(struct sk_buff *skb, struct net_device *dev)
 	}
 
 	mapping = dma_map_single(bp->sdev->dma_dev, skb->data, len, DMA_TO_DEVICE);
-	if (dma_mapping_error(bp->sdev->dma_dev, mapping) || mapping + len > DMA_BIT_MASK(30)) {
-		struct sk_buff *bounce_skb;
+    
+    if (dma_mapping_error(bp->sdev->dma_dev, mapping)) {
+        dev_kfree_skb_any(skb);
+        return NETDEV_TX_OK;
+    }
+
+    if (mapping + len > DMA_BIT_MASK(30)) {
+        struct sk_buff *bounce_skb;
 
 		/* Chip can't handle DMA to/from >1GB, use bounce buffer */
 		if (!dma_mapping_error(bp->sdev->dma_dev, mapping))
-- 
2.47.3


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

end of thread, other threads:[~2026-03-23 21:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 18:09 [PATCH] net: broadcom: b44: Add missing dma_mapping_error in b44_start_xmit Adriano Vero
2026-03-23 21:23 ` Jakub Kicinski

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