Skip to content

Commit 46c6685

Browse files
krzkTzung-Bi Shih
authored andcommitted
firmware: coreboot: store owner from modules with coreboot_driver_register()
Modules registering driver with coreboot_driver_register() might forget to set .owner field. The field is used by some of other kernel parts for reference counting (try_module_get()), so it is expected that drivers will set it. Solve the problem by moving this task away from the drivers to the core code, just like we did for platform_driver in commit 9447057 ("platform_device: use a macro instead of platform_driver_register"). Moving the .owner setting code to the core this effectively fixes missing .owner in framebuffer-coreboot, memconsole-coreboot and vpd drivers. Signed-off-by: Krzysztof Kozlowski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Tzung-Bi Shih <[email protected]>
1 parent 4cece76 commit 46c6685

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

drivers/firmware/google/coreboot_table.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,15 @@ static void coreboot_device_release(struct device *dev)
8585
kfree(device);
8686
}
8787

88-
int coreboot_driver_register(struct coreboot_driver *driver)
88+
int __coreboot_driver_register(struct coreboot_driver *driver,
89+
struct module *owner)
8990
{
9091
driver->drv.bus = &coreboot_bus_type;
92+
driver->drv.owner = owner;
9193

9294
return driver_register(&driver->drv);
9395
}
94-
EXPORT_SYMBOL(coreboot_driver_register);
96+
EXPORT_SYMBOL(__coreboot_driver_register);
9597

9698
void coreboot_driver_unregister(struct coreboot_driver *driver)
9799
{

drivers/firmware/google/coreboot_table.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,12 @@ struct coreboot_driver {
9797
const struct coreboot_device_id *id_table;
9898
};
9999

100+
/* use a macro to avoid include chaining to get THIS_MODULE */
101+
#define coreboot_driver_register(driver) \
102+
__coreboot_driver_register(driver, THIS_MODULE)
100103
/* Register a driver that uses the data from a coreboot table. */
101-
int coreboot_driver_register(struct coreboot_driver *driver);
104+
int __coreboot_driver_register(struct coreboot_driver *driver,
105+
struct module *owner);
102106

103107
/* Unregister a driver that uses the data from a coreboot table. */
104108
void coreboot_driver_unregister(struct coreboot_driver *driver);

0 commit comments

Comments
 (0)