Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

driver core: faux: stop using static struct device

faux_bus_root should not have been a static struct device, but rather a
dynamically created structure so that lockdep and other testing tools do
not trip over it (as well as being the right thing overall to do.) Fix
this up by making it properly dynamic.

Reported-by: Gui-Dong Han <hanguidong02@gmail.com>
Closes: https://lore.kernel.org/lkml/CALbr=LYKJsj6cbrDLA07qioKhWJcRj+gW8=bq5=4ZvpEe2c4Yg@mail.gmail.com/
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/2026012145-lapping-countless-ef81@gregkh
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

+11 -7
+11 -7
drivers/base/faux.c
··· 29 29 }; 30 30 #define to_faux_object(dev) container_of_const(dev, struct faux_object, faux_dev.dev) 31 31 32 - static struct device faux_bus_root = { 33 - .init_name = "faux", 34 - }; 32 + static struct device *faux_bus_root; 35 33 36 34 static int faux_match(struct device *dev, const struct device_driver *drv) 37 35 { ··· 150 152 if (parent) 151 153 dev->parent = parent; 152 154 else 153 - dev->parent = &faux_bus_root; 155 + dev->parent = faux_bus_root; 154 156 dev->bus = &faux_bus_type; 155 157 dev_set_name(dev, "%s", name); 156 158 device_set_pm_not_required(dev); ··· 234 236 { 235 237 int ret; 236 238 237 - ret = device_register(&faux_bus_root); 239 + faux_bus_root = kzalloc(sizeof(*faux_bus_root), GFP_KERNEL); 240 + if (!faux_bus_root) 241 + return -ENOMEM; 242 + 243 + dev_set_name(faux_bus_root, "faux"); 244 + 245 + ret = device_register(faux_bus_root); 238 246 if (ret) { 239 - put_device(&faux_bus_root); 247 + put_device(faux_bus_root); 240 248 return ret; 241 249 } 242 250 ··· 260 256 bus_unregister(&faux_bus_type); 261 257 262 258 error_bus: 263 - device_unregister(&faux_bus_root); 259 + device_unregister(faux_bus_root); 264 260 return ret; 265 261 }