* [PATCH net-next v4] net: core: failover: enforce mandatory ops and clean up redundant checks
@ 2026-03-02 6:43 Zeeshan Ahmad
2026-03-04 2:10 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Zeeshan Ahmad @ 2026-03-02 6:43 UTC (permalink / raw)
To: Sridhar Samudrala, David S . Miller, Jakub Kicinski, Paolo Abeni,
Eric Dumazet
Cc: netdev, kernel-janitors, linux-kernel, Simon Horman,
Dan Carpenter, Zeeshan Ahmad
The failover framework requires 'ops' to be functional. Currently,
failover_register() allows an instance to be registered with NULL
ops, which leads to inconsistent NULL checks and potential NULL
pointer dereferences in the slave registration paths.
Harden the entry point by requiring non-NULL ops in
failover_register(). This ensures the 'fops' pointer is guaranteed
to be valid for any successfully registered failover instance.
Consequently, remove the now redundant NULL checks for 'fops'
throughout the module to simplify the logic.
Signed-off-by: Zeeshan Ahmad <zeeshanahmad022019@gmail.com>
---
v4:
- Harden failover_register() to forbid NULL ops as suggested by
Jakub Kicinski.
- Remove all redundant NULL checks for fops throughout the module.
- Remove the Fixes tag and target net-next, as this is now categorized
as a refactor/cleanup rather than a standalone bug fix.
v3:
- Move the fops NULL check to the top of the function before any
dereferences occur, as suggested by Dan Carpenter.
v2:
- Wrap the dereference in an if(fops) block instead of an early return
based on feedback from Simon Horman.
net/core/failover.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/net/core/failover.c b/net/core/failover.c
index 0eb2e0ec875b..11bb183c7a1b 100644
--- a/net/core/failover.c
+++ b/net/core/failover.c
@@ -59,7 +59,7 @@ static int failover_slave_register(struct net_device *slave_dev)
if (!failover_dev)
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;
@@ -115,7 +115,7 @@ int failover_slave_unregister(struct net_device *slave_dev)
if (!failover_dev)
goto done;
- if (fops && fops->slave_pre_unregister &&
+ if (fops->slave_pre_unregister &&
fops->slave_pre_unregister(slave_dev, failover_dev))
goto done;
@@ -123,7 +123,7 @@ int failover_slave_unregister(struct net_device *slave_dev)
netdev_upper_dev_unlink(slave_dev, failover_dev);
slave_dev->priv_flags &= ~(IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF);
- if (fops && fops->slave_unregister &&
+ if (fops->slave_unregister &&
!fops->slave_unregister(slave_dev, failover_dev))
return NOTIFY_OK;
@@ -149,7 +149,7 @@ static int failover_slave_link_change(struct net_device *slave_dev)
if (!netif_running(failover_dev))
goto done;
- if (fops && fops->slave_link_change &&
+ if (fops->slave_link_change &&
!fops->slave_link_change(slave_dev, failover_dev))
return NOTIFY_OK;
@@ -174,7 +174,7 @@ static int failover_slave_name_change(struct net_device *slave_dev)
if (!netif_running(failover_dev))
goto done;
- if (fops && fops->slave_name_change &&
+ if (fops->slave_name_change &&
!fops->slave_name_change(slave_dev, failover_dev))
return NOTIFY_OK;
@@ -244,7 +244,7 @@ struct failover *failover_register(struct net_device *dev,
{
struct failover *failover;
- if (dev->type != ARPHRD_ETHER)
+ if (dev->type != ARPHRD_ETHER || !ops)
return ERR_PTR(-EINVAL);
failover = kzalloc_obj(*failover);
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v4] net: core: failover: enforce mandatory ops and clean up redundant checks
2026-03-02 6:43 [PATCH net-next v4] net: core: failover: enforce mandatory ops and clean up redundant checks Zeeshan Ahmad
@ 2026-03-04 2:10 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-03-04 2:10 UTC (permalink / raw)
To: Zeeshan Ahmad
Cc: sridhar.samudrala, davem, kuba, pabeni, edumazet, netdev,
kernel-janitors, linux-kernel, horms, dan.carpenter
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 2 Mar 2026 11:43:17 +0500 you wrote:
> The failover framework requires 'ops' to be functional. Currently,
> failover_register() allows an instance to be registered with NULL
> ops, which leads to inconsistent NULL checks and potential NULL
> pointer dereferences in the slave registration paths.
>
> Harden the entry point by requiring non-NULL ops in
> failover_register(). This ensures the 'fops' pointer is guaranteed
> to be valid for any successfully registered failover instance.
> Consequently, remove the now redundant NULL checks for 'fops'
> throughout the module to simplify the logic.
>
> [...]
Here is the summary with links:
- [net-next,v4] net: core: failover: enforce mandatory ops and clean up redundant checks
https://git.kernel.org/netdev/net-next/c/d6ca199568c5
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-04 2:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02 6:43 [PATCH net-next v4] net: core: failover: enforce mandatory ops and clean up redundant checks Zeeshan Ahmad
2026-03-04 2:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox