static int __init cpu_smt_sysfs_init(void)
 {
-       return sysfs_create_group(&cpu_subsys.dev_root->kobj,
-                                 &cpuhp_smt_attr_group);
+       struct device *dev_root;
+       int ret = -ENODEV;
+
+       dev_root = bus_get_dev_root(&cpu_subsys);
+       if (dev_root) {
+               ret = sysfs_create_group(&dev_root->kobj, &cpuhp_smt_attr_group);
+               put_device(dev_root);
+       }
+       return ret;
 }
 
 static int __init cpuhp_sysfs_init(void)
 {
+       struct device *dev_root;
        int cpu, ret;
 
        ret = cpu_smt_sysfs_init();
        if (ret)
                return ret;
 
-       ret = sysfs_create_group(&cpu_subsys.dev_root->kobj,
-                                &cpuhp_cpu_root_attr_group);
-       if (ret)
-               return ret;
+       dev_root = bus_get_dev_root(&cpu_subsys);
+       if (dev_root) {
+               ret = sysfs_create_group(&dev_root->kobj, &cpuhp_cpu_root_attr_group);
+               put_device(dev_root);
+               if (ret)
+                       return ret;
+       }
 
        for_each_possible_cpu(cpu) {
                struct device *dev = get_cpu_device(cpu);