Thread (2 messages) 2 messages, 2 authors, 2026-02-26
STALE139d

[PATCH net v2] net: core: failover: fix NULL pointer dereference in failover_slave_register()

From: Zeeshan Ahmad <hidden>
Date: 2026-02-26 07:58:12
Also in: kernel-janitors, lkml
Subsystem: failover module, networking [general], the rest · Maintainers: Sridhar Samudrala, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Smatch warns that 'fops' is dereferenced at line 69 without a NULL check.
While other callbacks in this function properly check 'fops', the
rx_handler registration does not.

If failover_get_bymac() returns a valid failover_dev but a NULL fops,
the kernel will encounter a NULL pointer dereference when registering
the rx_handler.

Following the pattern of other failover callers, add a WARN_ON_ONCE()
to catch this misconfiguration. Abort the registration if fops is
missing to prevent an inconsistent state where a slave is logically
linked to a master but lacks a functional data path hook.

Fixes: 30c8bd5aa8b2 ("net: Introduce generic failover module")
Signed-off-by: Zeeshan Ahmad <redacted>
---
v2:
 - Target 'net' tree as this is a bug fix.
 - Change logic from an early return (v1) to WARN_ON_ONCE() and abort
   registration to prevent inconsistent state, as discussed with
   Simon Horman.
 - Update commit message with detailed impact analysis.

 net/core/failover.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/net/core/failover.c b/net/core/failover.c
index 2a140b3ea669..1702bb1feca1 100644
--- a/net/core/failover.c
+++ b/net/core/failover.c
@@ -63,6 +63,9 @@ static int failover_slave_register(struct net_device *slave_dev)
 	    fops->slave_pre_register(slave_dev, failover_dev))
 		goto done;
 
+	if (WARN_ON_ONCE(!fops))
+		goto done;
+
 	err = netdev_rx_handler_register(slave_dev, fops->slave_handle_frame,
 					 failover_dev);
 	if (err) {
-- 
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help