netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: dl2k: fix potential null deref in receive_packet()
@ 2025-03-21 12:13 Qasim Ijaz
  2025-03-21 15:13 ` Eric Dumazet
  0 siblings, 1 reply; 3+ messages in thread
From: Qasim Ijaz @ 2025-03-21 12:13 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni, yyyynoom, horms
  Cc: netdev, linux-kernel

If the pkt_len is less than the copy_thresh the netdev_alloc_skb_ip_align()
is called to allocate an skbuff, on failure it can return NULL. Since
there is no NULL check a NULL deref can occur when setting
skb->protocol.

Fix this by introducing a NULL check to handle allocation failure.

Fixes: 89d71a66c40d ("net: Use netdev_alloc_skb_ip_align()")
Signed-off-by: Qasim Ijaz <qasdev00@gmail.com>
---
 drivers/net/ethernet/dlink/dl2k.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
index d0ea92607870..22e9432adea0 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -968,6 +968,11 @@ receive_packet (struct net_device *dev)
 							   np->rx_buf_sz,
 							   DMA_FROM_DEVICE);
 			}
+
+			if (unlikely(!skb)) {
+				np->rx_ring[entry].fraginfo = 0;
+				break;
+			}
 			skb->protocol = eth_type_trans (skb, dev);
 #if 0
 			/* Checksum done by hw, but csum value unavailable. */
-- 
2.39.5


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

end of thread, other threads:[~2025-03-21 18:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-21 12:13 [PATCH] net: dl2k: fix potential null deref in receive_packet() Qasim Ijaz
2025-03-21 15:13 ` Eric Dumazet
2025-03-21 18:42   ` Qasim Ijaz

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).