* [PATCH net-next v2] ipv4: nexthop: handle errors in nexthop_init()
@ 2026-07-31 2:52 Minhong He
2026-08-02 6:28 ` Ido Schimmel
0 siblings, 1 reply; 2+ messages in thread
From: Minhong He @ 2026-07-31 2:52 UTC (permalink / raw)
To: David Ahern, Ido Schimmel, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman, netdev
Cc: linux-kernel
nexthop_init() ignores errors from register_pernet_subsys() and
register_netdevice_notifier(), so a partial initialization can appear
successful.
Check those steps and unwind prior registrations on failure.
Do not check rtnl_register_many(): for built-in code it panics on
failure, so the call cannot return an error to nexthop_init().
Signed-off-by: Minhong He <heminhong@kylinos.cn>
---
v2:
- Drop rtnl_register_many() error handling; built-in registration panics
on failure
- Retarget to net-next
v1: https://lore.kernel.org/all/20260728031055.76708-1-heminhong@kylinos.cn/
net/ipv4/nexthop.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index 6205bd57aa85..aa2fa17391e7 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -4192,12 +4192,22 @@ static const struct rtnl_msg_handler nexthop_rtnl_msg_handlers[] __initconst = {
static int __init nexthop_init(void)
{
- register_pernet_subsys(&nexthop_net_ops);
+ int err;
- register_netdevice_notifier(&nh_netdev_notifier);
+ err = register_pernet_subsys(&nexthop_net_ops);
+ if (err)
+ return err;
+
+ err = register_netdevice_notifier(&nh_netdev_notifier);
+ if (err)
+ goto err_unregister_pernet;
rtnl_register_many(nexthop_rtnl_msg_handlers);
return 0;
+
+err_unregister_pernet:
+ unregister_pernet_subsys(&nexthop_net_ops);
+ return err;
}
subsys_initcall(nexthop_init);
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next v2] ipv4: nexthop: handle errors in nexthop_init()
2026-07-31 2:52 [PATCH net-next v2] ipv4: nexthop: handle errors in nexthop_init() Minhong He
@ 2026-08-02 6:28 ` Ido Schimmel
0 siblings, 0 replies; 2+ messages in thread
From: Ido Schimmel @ 2026-08-02 6:28 UTC (permalink / raw)
To: Minhong He
Cc: David Ahern, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, netdev, linux-kernel
On Fri, Jul 31, 2026 at 10:52:49AM +0800, Minhong He wrote:
> nexthop_init() ignores errors from register_pernet_subsys() and
> register_netdevice_notifier(), so a partial initialization can appear
> successful.
>
> Check those steps and unwind prior registrations on failure.
>
> Do not check rtnl_register_many(): for built-in code it panics on
> failure, so the call cannot return an error to nexthop_init().
>
> Signed-off-by: Minhong He <heminhong@kylinos.cn>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-02 6:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31 2:52 [PATCH net-next v2] ipv4: nexthop: handle errors in nexthop_init() Minhong He
2026-08-02 6:28 ` Ido Schimmel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox