From: Vasiliy Kovalev kovalev@altlinux.org
mainline inclusion from mainline-v6.8-rc6 commit def689fc26b9a9622d2e2cb0c4933dd3b1c8071c category: bugfix bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9E2M1 CVE: CVE-2024-26734
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
The pernet operations structure for the subsystem must be registered before registering the generic netlink family.
Make an unregister in case of unsuccessful registration.
Fixes: 687125b5799c ("devlink: split out core code") Signed-off-by: Vasiliy Kovalev kovalev@altlinux.org Link: https://lore.kernel.org/r/20240215203400.29976-1-kovalev@altlinux.org Signed-off-by: Paolo Abeni pabeni@redhat.com Conflicts: net/core/devlink.c Signed-off-by: Jialin Zhang zhangjialin11@huawei.com --- net/core/devlink.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/core/devlink.c b/net/core/devlink.c index 38666dde8934..99939fb05ca9 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -10340,10 +10340,14 @@ static int __init devlink_init(void) { int err;
- err = genl_register_family(&devlink_nl_family); + err = register_pernet_subsys(&devlink_pernet_ops); if (err) goto out; - err = register_pernet_subsys(&devlink_pernet_ops); + err = genl_register_family(&devlink_nl_family); + if (!err) + return 0; + + unregister_pernet_subsys(&devlink_pernet_ops);
out: WARN_ON(err);