Skip to content

Commit 550131b

Browse files
committed
NVIDIA: VR: SAUCE: fwctl: Fix class init ordering to avoid NULL pointer dereference on device removal
CXL is linked before fwctl in drivers/Makefile. Both use `module_init, so `cxl_pci_driver_init()` runs first. When `cxl_pci_probe()` calls `fwctl_register()` and then `device_add()`, fwctl_class is not yet registered because fwctl_init() hasn't run, causing `class_to_subsys()` to return NULL and skip knode_class initialization. On device removal, `class_to_subsys()` returns non-NULL, and `device_del()` calls `klist_del()` on the uninitialized knode, triggering a NULL pointer dereference [1]. Fixes: 858ce2f ("cxl: Add FWCTL support to CXL") Reviewed-by: Kai-Heng Feng <kaihengf@nvidia.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Richard Cheng <icheng@nvidia.com> (backported from https://lore.kernel.org/all/20260409051902.40218-1-icheng@nvidia.com/) Signed-off-by: Richard Cheng <icheng@nvidia.com>
1 parent 469b525 commit 550131b

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/fwctl/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static void __exit fwctl_exit(void)
415415
unregister_chrdev_region(fwctl_dev, FWCTL_MAX_DEVICES);
416416
}
417417

418-
module_init(fwctl_init);
418+
subsys_initcall(fwctl_init);
419419
module_exit(fwctl_exit);
420420
MODULE_DESCRIPTION("fwctl device firmware access framework");
421421
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)