Patch "devlink: fix possible use-after-free and memory leaks in devlink_init()" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    devlink: fix possible use-after-free and memory leaks in devlink_init()

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     devlink-fix-possible-use-after-free-and-memory-leaks.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 69f5ecd1fb1990123d598aae76f59ed667a95262
Author: Vasiliy Kovalev <kovalev@xxxxxxxxxxxx>
Date:   Thu Feb 15 23:34:00 2024 +0300

    devlink: fix possible use-after-free and memory leaks in devlink_init()
    
    [ Upstream commit def689fc26b9a9622d2e2cb0c4933dd3b1c8071c ]
    
    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@xxxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240215203400.29976-1-kovalev@xxxxxxxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/devlink/core.c b/net/devlink/core.c
index 6cec4afb01fbd..451f2bc141a05 100644
--- a/net/devlink/core.c
+++ b/net/devlink/core.c
@@ -308,14 +308,20 @@ static int __init devlink_init(void)
 {
 	int err;
 
-	err = genl_register_family(&devlink_nl_family);
-	if (err)
-		goto out;
 	err = register_pernet_subsys(&devlink_pernet_ops);
 	if (err)
 		goto out;
+	err = genl_register_family(&devlink_nl_family);
+	if (err)
+		goto out_unreg_pernet_subsys;
 	err = register_netdevice_notifier(&devlink_port_netdevice_nb);
+	if (!err)
+		return 0;
+
+	genl_unregister_family(&devlink_nl_family);
 
+out_unreg_pernet_subsys:
+	unregister_pernet_subsys(&devlink_pernet_ops);
 out:
 	WARN_ON(err);
 	return err;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux