diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-09 12:35:56 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-02-10 12:16:42 +0300 |
commit | 8c99377e614f8abfd881c34611002b2af5ab1ee8 (patch) | |
tree | 2122c752dc8c47b6be963a18fcfecab2f8735417 /drivers/base/cpu.c | |
parent | ad8685d0f61a6fc1dc2e5874f4924ff5028c5954 (diff) | |
download | linux-8c99377e614f8abfd881c34611002b2af5ab1ee8.tar.xz |
driver core: bus: add bus_get_dev_root() function
Instead of poking around in the struct bus_type directly for the
dev_root pointer, provide a function to return it properly reference
counted, if it is present in the bus. This will be needed to move the
pointer out of struct bus_type in the future.
Use the function in the driver core code at the same time it is
introduced to verify that it works properly.
Cc: "Rafael J. Wysocki" <rafael@kernel.org>
Link: https://lore.kernel.org/r/20230209093556.19132-1-gregkh@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/cpu.c')
-rw-r--r-- | drivers/base/cpu.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c index 441eb5bdec7d..8bb623039bb2 100644 --- a/drivers/base/cpu.c +++ b/drivers/base/cpu.c @@ -610,9 +610,13 @@ static const struct attribute_group cpu_root_vulnerabilities_group = { static void __init cpu_register_vulnerabilities(void) { - if (sysfs_create_group(&cpu_subsys.dev_root->kobj, - &cpu_root_vulnerabilities_group)) - pr_err("Unable to register CPU vulnerabilities\n"); + struct device *dev = bus_get_dev_root(&cpu_subsys); + + if (dev) { + if (sysfs_create_group(&dev->kobj, &cpu_root_vulnerabilities_group)) + pr_err("Unable to register CPU vulnerabilities\n"); + put_device(dev); + } } #else |