]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
slimbus: core: fix OF node leak on registration failure
authorJohan Hovold <johan@kernel.org>
Wed, 26 Nov 2025 14:53:24 +0000 (15:53 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Jan 2026 15:43:04 +0000 (16:43 +0100)
Make sure to drop the OF node reference taken when initialising and
registering the slimbus device also on registration failure by releasing
it in the destructor as expected.

Fixes: 7588a511bdb4 ("slimbus: core: add support to device tree helper")
Fixes: 01360857486c ("slimbus: core: Fix mismatch in of_node_get/put")
Cc: Saravana Kannan <saravanak@google.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20251126145329.5022-2-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/slimbus/core.c

index 005fa2ef100f526df5603d212b6334c06a366c94..c808233692ee4678d983058353cc5d2124ab0156 100644 (file)
@@ -146,6 +146,7 @@ static void slim_dev_release(struct device *dev)
 {
        struct slim_device *sbdev = to_slim_device(dev);
 
+       of_node_put(sbdev->dev.of_node);
        kfree(sbdev);
 }
 
@@ -280,7 +281,6 @@ EXPORT_SYMBOL_GPL(slim_register_controller);
 /* slim_remove_device: Remove the effect of slim_add_device() */
 static void slim_remove_device(struct slim_device *sbdev)
 {
-       of_node_put(sbdev->dev.of_node);
        device_unregister(&sbdev->dev);
 }