]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mctp: check register_netdevice_notifier() error in mctp_device_init()
authorMinhong He <heminhong@kylinos.cn>
Mon, 20 Jul 2026 07:25:18 +0000 (15:25 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 23 Jul 2026 16:17:36 +0000 (09:17 -0700)
mctp_device_init() handles errors from rtnl_af_register() and
rtnl_register_many(), but ignores the return value of
register_netdevice_notifier(). If notifier registration fails, init can
still return success while the module is only partially initialized.

Check the notifier registration error and fail module init early.

Fixes: 583be982d934 ("mctp: Add device handling and netlink interface")
Signed-off-by: Minhong He <heminhong@kylinos.cn>
Link: https://patch.msgid.link/20260720072518.112614-1-heminhong@kylinos.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/mctp/device.c

index 2c84df674669b287e62a1a2f81a5f0e9f2ebf418..822120e860c82a30891f2b8105d5335730ea8ab2 100644 (file)
@@ -536,7 +536,9 @@ int __init mctp_device_init(void)
 {
        int err;
 
-       register_netdevice_notifier(&mctp_dev_nb);
+       err = register_netdevice_notifier(&mctp_dev_nb);
+       if (err)
+               return err;
 
        err = rtnl_af_register(&mctp_af_ops);
        if (err)