[PATCH net v2] ipv6: sr: Add NULL check for idev in seg6_hmac_validate_skb

From: Minhong He

Date: Thu Mar 12 2026 - 22:27:39 EST


In seg6_hmac_validate_skb(), the pointer returned by __in6_dev_get()
can be NULL if the network device lacks proper IPv6 initialization
or is being torn down. Add a NULL check to avoid potential NULL pointer
dereference in subsequent code.

Fixes: bf355b8d2c30 ("ipv6: sr: add core files for SR HMAC support")
Signed-off-by: Minhong He <heminhong@xxxxxxxxxx>
---
net/ipv6/seg6_hmac.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/net/ipv6/seg6_hmac.c b/net/ipv6/seg6_hmac.c
index ee6bac0160ac..e6964c6b0d38 100644
--- a/net/ipv6/seg6_hmac.c
+++ b/net/ipv6/seg6_hmac.c
@@ -184,6 +184,8 @@ bool seg6_hmac_validate_skb(struct sk_buff *skb)
int require_hmac;

idev = __in6_dev_get(skb->dev);
+ if (!idev)
+ return false;

srh = (struct ipv6_sr_hdr *)skb_transport_header(skb);

--
2.25.1