phonet_device_init() registers a netdevice notifier before calling phonet_netlink_register(), but does not check whether notifier registration succeeded. On failure, netlink setup still proceeds and init may return success without the notifier in place. Check the notifier registration error and unwind only the resources that were already registered (proc entry and pernet), without calling unregister_netdevice_notifier() for a notifier that was never registered. Fixes: f8ff60283de2 ("Phonet: network device and address handling") Signed-off-by: Minhong He --- v2: - On notifier registration failure, unwind only proc/pernet; do not call phonet_device_exit() / unregister_netdevice_notifier() for a notifier that was never registered. v1: https://lore.kernel.org/netdev/20260713075212.431455-1-heminhong@kylinos.cn/ net/phonet/pn_dev.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/phonet/pn_dev.c b/net/phonet/pn_dev.c index ad44831d6745..e6c31cfdad9a 100644 --- a/net/phonet/pn_dev.c +++ b/net/phonet/pn_dev.c @@ -356,7 +356,12 @@ int __init phonet_device_init(void) proc_create_net("pnresource", 0, init_net.proc_net, &pn_res_seq_ops, sizeof(struct seq_net_private)); - register_netdevice_notifier(&phonet_device_notifier); + err = register_netdevice_notifier(&phonet_device_notifier); + if (err) { + remove_proc_entry("pnresource", init_net.proc_net); + unregister_pernet_subsys(&phonet_net_ops); + return err; + } err = phonet_netlink_register(); if (err) phonet_device_exit(); -- 2.25.1