Commit 2c119aa8 authored by Russell King's avatar Russell King Committed by Russell King

[DRIVER MODEL] Fix sgivwfb

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 abbf268a
...@@ -751,10 +751,6 @@ int __init sgivwfb_setup(char *options) ...@@ -751,10 +751,6 @@ int __init sgivwfb_setup(char *options)
/* /*
* Initialisation * Initialisation
*/ */
static void sgivwfb_release(struct device *device)
{
}
static int __init sgivwfb_probe(struct device *device) static int __init sgivwfb_probe(struct device *device)
{ {
struct platform_device *dev = to_platform_device(device); struct platform_device *dev = to_platform_device(device);
...@@ -859,13 +855,7 @@ static struct device_driver sgivwfb_driver = { ...@@ -859,13 +855,7 @@ static struct device_driver sgivwfb_driver = {
.remove = sgivwfb_remove, .remove = sgivwfb_remove,
}; };
static struct platform_device sgivwfb_device = { static struct platform_device *sgivwfb_device;
.name = "sgivwfb",
.id = 0,
.dev = {
.release = sgivwfb_release,
}
};
int __init sgivwfb_init(void) int __init sgivwfb_init(void)
{ {
...@@ -880,9 +870,15 @@ int __init sgivwfb_init(void) ...@@ -880,9 +870,15 @@ int __init sgivwfb_init(void)
#endif #endif
ret = driver_register(&sgivwfb_driver); ret = driver_register(&sgivwfb_driver);
if (!ret) { if (!ret) {
ret = platform_device_register(&sgivwfb_device); sgivwfb_device = platform_device_alloc("sgivwfb", 0);
if (ret) if (sgivwfb_device) {
ret = platform_device_add(sgivwfb_device);
} else
ret = -ENOMEM;
if (ret) {
driver_unregister(&sgivwfb_driver); driver_unregister(&sgivwfb_driver);
platform_device_put(sgivwfb_device);
}
} }
return ret; return ret;
} }
...@@ -894,7 +890,7 @@ MODULE_LICENSE("GPL"); ...@@ -894,7 +890,7 @@ MODULE_LICENSE("GPL");
static void __exit sgivwfb_exit(void) static void __exit sgivwfb_exit(void)
{ {
platform_device_unregister(&sgivwfb_device); platform_device_unregister(sgivwfb_device);
driver_unregister(&sgivwfb_driver); driver_unregister(&sgivwfb_driver);
} }
......
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