From: Zeeshan Ahmad <zeeshanahmad022019@gmail.com>
To: Sridhar Samudrala <sridhar.samudrala@intel.com>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Eric Dumazet <edumazet@google.com>
Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
linux-kernel@vger.kernel.org, Simon Horman <horms@kernel.org>,
Zeeshan Ahmad <zeeshanahmad022019@gmail.com>
Subject: [PATCH net-next v1] net: core: fix logical inconsistency in failover_slave_register()
Date: Thu, 19 Feb 2026 14:02:16 +0500 [thread overview]
Message-ID: <20260219090216.12884-1-zeeshanahmad022019@gmail.com> (raw)
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
next reply other threads:[~2026-02-19 9:02 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 9:02 Zeeshan Ahmad [this message]
2026-02-19 9:40 ` [PATCH net-next v1] net: core: fix logical inconsistency in failover_slave_register() Simon Horman
2026-02-25 10:04 ` Zeeshan Ahmad
2026-02-25 13:31 ` Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260219090216.12884-1-zeeshanahmad022019@gmail.com \
--to=zeeshanahmad022019@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sridhar.samudrala@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox