* [PATCH net v4] net: dlink: handle copy_thresh allocation failure
@ 2025-09-28 19:01 Yeounsu Moon
2025-09-30 2:00 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Yeounsu Moon @ 2025-09-28 19:01 UTC (permalink / raw)
To: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: netdev, linux-kernel, Yeounsu Moon, Andrew Lunn
The driver did not handle failure of `netdev_alloc_skb_ip_align()`.
If the allocation failed, dereferencing `skb->protocol` could lead to
a NULL pointer dereference.
This patch tries to allocate `skb`. If the allocation fails, it falls
back to the normal path.
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: Jakub Kicinski <kuba@kernel.org>
Tested-on: D-Link DGE-550T Rev-A3
Signed-off-by: Yeounsu Moon <yyyynoom@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/ethernet/dlink/dl2k.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
---
Changelog:
v4:
- consolidated into a single patch
- removed goto statement, per Jakub's suggestion
- reorder changelog for clarity
v3: https://lore.kernel.org/netdev/20250916183305.2808-1-yyyynoom@gmail.com/
- change confusing label name
v2: https://lore.kernel.org/netdev/20250914182653.3152-4-yyyynoom@gmail.com/
- split into two patches: whitespace cleanup and functional fix
v1: https://lore.kernel.org/netdev/20250912145339.67448-2-yyyynoom@gmail.com/
---
diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c
index 6bbf6e5584e5..1996d2e4e3e2 100644
--- a/drivers/net/ethernet/dlink/dl2k.c
+++ b/drivers/net/ethernet/dlink/dl2k.c
@@ -964,15 +964,18 @@ receive_packet (struct net_device *dev)
} else {
struct sk_buff *skb;
+ skb = NULL;
/* Small skbuffs for short packets */
- if (pkt_len > copy_thresh) {
+ if (pkt_len <= copy_thresh)
+ skb = netdev_alloc_skb_ip_align(dev, pkt_len);
+ if (!skb) {
dma_unmap_single(&np->pdev->dev,
desc_to_dma(desc),
np->rx_buf_sz,
DMA_FROM_DEVICE);
skb_put (skb = np->rx_skbuff[entry], pkt_len);
np->rx_skbuff[entry] = NULL;
- } else if ((skb = netdev_alloc_skb_ip_align(dev, pkt_len))) {
+ } else {
dma_sync_single_for_cpu(&np->pdev->dev,
desc_to_dma(desc),
np->rx_buf_sz,
--
2.51.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net v4] net: dlink: handle copy_thresh allocation failure
2025-09-28 19:01 [PATCH net v4] net: dlink: handle copy_thresh allocation failure Yeounsu Moon
@ 2025-09-30 2:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-09-30 2:00 UTC (permalink / raw)
To: Yeounsu Moon
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, netdev,
linux-kernel, andrew
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 29 Sep 2025 04:01:24 +0900 you wrote:
> The driver did not handle failure of `netdev_alloc_skb_ip_align()`.
> If the allocation failed, dereferencing `skb->protocol` could lead to
> a NULL pointer dereference.
>
> This patch tries to allocate `skb`. If the allocation fails, it falls
> back to the normal path.
>
> [...]
Here is the summary with links:
- [net,v4] net: dlink: handle copy_thresh allocation failure
https://git.kernel.org/netdev/net/c/8169a6011c5f
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] 2+ messages in thread
end of thread, other threads:[~2025-09-30 2:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-28 19:01 [PATCH net v4] net: dlink: handle copy_thresh allocation failure Yeounsu Moon
2025-09-30 2:00 ` 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
Powered by JetHome