]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
isa: switch to dynamic root device
authorJohan Hovold <johan@kernel.org>
Fri, 24 Apr 2026 10:24:00 +0000 (12:24 +0200)
committerDanilo Krummrich <dakr@kernel.org>
Mon, 4 May 2026 20:05:03 +0000 (22:05 +0200)
Driver core expects devices to be dynamically allocated and will, for
example, complain loudly if a device that lacks a release function is
ever freed.

Use root_device_register() to allocate and register the root device
instead of open coding using a static device.

Note that this also fixes a reference leak in case device_register()
fails which may be flagged by static checkers.

Signed-off-by: Johan Hovold <johan@kernel.org>
Acked-by: William Breathitt Gray <wbg@kernel.org>
Link: https://patch.msgid.link/20260424102400.2615677-1-johan@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
drivers/base/isa.c

index fd076cc63cb6540b68d3497afb877dfbd314d78f..5887e4211f80ba4a5c8d698b7c5af4c2e0a63b96 100644 (file)
@@ -11,9 +11,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/isa.h>
 
-static struct device isa_bus = {
-       .init_name      = "isa"
-};
+static struct device *isa_bus;
 
 struct isa_dev {
        struct device dev;
@@ -131,7 +129,7 @@ int isa_register_driver(struct isa_driver *isa_driver, unsigned int ndev)
                        break;
                }
 
-               isa_dev->dev.parent     = &isa_bus;
+               isa_dev->dev.parent     = isa_bus;
                isa_dev->dev.bus        = &isa_bus_type;
 
                dev_set_name(&isa_dev->dev, "%s.%u",
@@ -169,9 +167,11 @@ static int __init isa_bus_init(void)
 
        error = bus_register(&isa_bus_type);
        if (!error) {
-               error = device_register(&isa_bus);
-               if (error)
+               isa_bus = root_device_register("isa");
+               if (IS_ERR(isa_bus)) {
+                       error = PTR_ERR(isa_bus);
                        bus_unregister(&isa_bus_type);
+               }
        }
        return error;
 }