public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v1] net: core: fix logical inconsistency in failover_slave_register()
@ 2026-02-19  9:02 Zeeshan Ahmad
  2026-02-19  9:40 ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Zeeshan Ahmad @ 2026-02-19  9:02 UTC (permalink / raw)
  To: Sridhar Samudrala, David S . Miller, Jakub Kicinski, Paolo Abeni,
	Eric Dumazet
  Cc: netdev, kernel-janitors, linux-kernel, Simon Horman,
	Zeeshan Ahmad

Smatch warns that 'fops' is dereferenced at line 66 before being checked
for NULL at line 85.

The current code inconsistently assumes 'fops' might be NULL at lines 62
and 85, while dereferencing it without a check at line 66.

Move the NULL check to the beginning of the function immediately after
'fops' is initialized. This ensures safety for all subsequent
dereferences and allows the removal of redundant checks.

Signed-off-by: Zeeshan Ahmad <zeeshanahmad022019@gmail.com>
---
 net/core/failover.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/failover.c b/net/core/failover.c
index 2a140b3ea669..88e376be0255 100644
--- a/net/core/failover.c
+++ b/net/core/failover.c
@@ -56,10 +56,10 @@ static int failover_slave_register(struct net_device *slave_dev)
 	ASSERT_RTNL();
 
 	failover_dev = failover_get_bymac(slave_dev->perm_addr, &fops);
-	if (!failover_dev)
+	if (!failover_dev || !fops)
 		goto done;
 
-	if (fops && fops->slave_pre_register &&
+	if (fops->slave_pre_register &&
 	    fops->slave_pre_register(slave_dev, failover_dev))
 		goto done;
 
@@ -82,7 +82,7 @@ static int failover_slave_register(struct net_device *slave_dev)
 
 	slave_dev->priv_flags |= (IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF);
 
-	if (fops && fops->slave_register &&
+	if (fops->slave_register &&
 	    !fops->slave_register(slave_dev, failover_dev))
 		return NOTIFY_OK;
 
-- 
2.43.0


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

end of thread, other threads:[~2026-02-25 13:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-19  9:02 [PATCH net-next v1] net: core: fix logical inconsistency in failover_slave_register() Zeeshan Ahmad
2026-02-19  9:40 ` Simon Horman
2026-02-25 10:04   ` Zeeshan Ahmad
2026-02-25 13:31     ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox