Commit abbf268a authored by Russell King's avatar Russell King Committed by Russell King

[DRIVER MODEL] Fix gbefb

Statically allocated devices in module data is a potential cause
of oopsen.  The device may be in use by a userspace process, which
will keep a reference to the device.  If the module is unloaded,
the module data will be freed.  Subsequent use of the platform
device will cause a kernel oops.

Use generic platform device allocation/release code in modules.
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 8d972a96
...@@ -1260,24 +1260,30 @@ static struct device_driver gbefb_driver = { ...@@ -1260,24 +1260,30 @@ static struct device_driver gbefb_driver = {
.remove = __devexit_p(gbefb_remove), .remove = __devexit_p(gbefb_remove),
}; };
static struct platform_device gbefb_device = { static struct platform_device *gbefb_device;
.name = "gbefb",
};
int __init gbefb_init(void) int __init gbefb_init(void)
{ {
int ret = driver_register(&gbefb_driver); int ret = driver_register(&gbefb_driver);
if (!ret) { if (!ret) {
ret = platform_device_register(&gbefb_device); gbefb_device = platform_device_alloc("gbefb", 0);
if (ret) if (gbefb_device) {
ret = platform_device_add(gbefb_device);
} else {
ret = -ENOMEM;
}
if (ret) {
platform_device_put(gbefb_device);
driver_unregister(&gbefb_driver); driver_unregister(&gbefb_driver);
}
} }
return ret; return ret;
} }
void __exit gbefb_exit(void) void __exit gbefb_exit(void)
{ {
driver_unregister(&gbefb_driver); platform_device_unregister(gbefb_device);
driver_unregister(&gbefb_driver);
} }
module_init(gbefb_init); module_init(gbefb_init);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment