Skip to contentSkip to conversation

net: avoid prefetching NULL pointers

PATCH Applied Eric Dumazet 3 participants 3 messages Dec 18, 2025 – Dec 28, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: avoid prefetching NULL pointers

Aditya Gupta reported PowerPC crashes bisected to the blamed commit.

Apparently some platforms do not allow prefetch() on arbitrary pointers.

  prefetch(next);
  prefetch(&next->priority); // CRASH when next == NULL

Only NULL seems to be supported, with specific handling in prefetch().

Add a conditional to avoid the two prefetches and the skb->next clearing for the last skb in the list.

---
 net/core/dev.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/core/dev.c +5 -3
index 9094c0fb8c68..36dc5199037e 100644
@@ -4241,9 +4241,11 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q,
 		int count = 0;
 
 		llist_for_each_entry_safe(skb, next, ll_list, ll_node) {
-			prefetch(next);
-			prefetch(&next->priority);
-			skb_mark_not_on_list(skb);
+			if (next) {
+				prefetch(next);
+				prefetch(&next->priority);
+				skb_mark_not_on_list(skb);
+			}
 			rc = dev_qdisc_enqueue(skb, q, &to_free, txq);
 			count++;
 		}
Signature · 1 line
2.52.0.313.g674ac2bdf7-goog
Tested-by on v1 1/1
#1 lore raw
Quoted 12 lines · Eric Dumazet

Aditya Gupta reported PowerPC crashes bisected to the blamed commit.

Apparently some platforms do not allow prefetch() on arbitrary pointers.

   prefetch(next);
   prefetch(&next->priority); // CRASH when next == NULL

Only NULL seems to be supported, with specific handling in prefetch().

Add a conditional to avoid the two prefetches and the skb->next clearing for the last skb in the list.

Quoted 7 lines
---
  net/core/dev.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 deletions(-)

Thanks for the quick fix Eric.

It fixes the reported kernel bug, hence:

Thanks,

- Aditya G

#2 lore raw
In reply to Eric Dumazet
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 8 lines · On Thu, 18 Dec 2025 08:18:44 +0000 you wrote:

Aditya Gupta reported PowerPC crashes bisected to the blamed commit.

Apparently some platforms do not allow prefetch() on arbitrary pointers.

  prefetch(next);
  prefetch(&next->priority); // CRASH when next == NULL

[...]

Here is the summary with links:
- [net] net: avoid prefetching NULL pointers

    https://git.kernel.org/netdev/net/c/c04de0c79534

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html