aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-11-05 16:22:39 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-11-05 16:22:39 -0500
commit2c119aa8091a15a87920f09aa0f17e05960fe11b (patch)
tree28871ec8da0830362f045906fb2b97722cb6837f
parentabbf268ae8f51e19779cdf3f5fbb8144f1a5fbc3 (diff)
[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: Russell King <rmk+kernel@arm.linux.org.uk> Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/video/sgivwfb.c24
1 files changed, 10 insertions, 14 deletions
diff --git a/drivers/video/sgivwfb.c b/drivers/video/sgivwfb.c
index cf5106eab2d5..5ce81f44c769 100644
--- a/drivers/video/sgivwfb.c
+++ b/drivers/video/sgivwfb.c
@@ -751,10 +751,6 @@ int __init sgivwfb_setup(char *options)
751/* 751/*
752 * Initialisation 752 * Initialisation
753 */ 753 */
754static void sgivwfb_release(struct device *device)
755{
756}
757
758static int __init sgivwfb_probe(struct device *device) 754static int __init sgivwfb_probe(struct device *device)
759{ 755{
760 struct platform_device *dev = to_platform_device(device); 756 struct platform_device *dev = to_platform_device(device);
@@ -859,13 +855,7 @@ static struct device_driver sgivwfb_driver = {
859 .remove = sgivwfb_remove, 855 .remove = sgivwfb_remove,
860}; 856};
861 857
862static struct platform_device sgivwfb_device = { 858static struct platform_device *sgivwfb_device;
863 .name = "sgivwfb",
864 .id = 0,
865 .dev = {
866 .release = sgivwfb_release,
867 }
868};
869 859
870int __init sgivwfb_init(void) 860int __init sgivwfb_init(void)
871{ 861{
@@ -880,9 +870,15 @@ int __init sgivwfb_init(void)
880#endif 870#endif
881 ret = driver_register(&sgivwfb_driver); 871 ret = driver_register(&sgivwfb_driver);
882 if (!ret) { 872 if (!ret) {
883 ret = platform_device_register(&sgivwfb_device); 873 sgivwfb_device = platform_device_alloc("sgivwfb", 0);
884 if (ret) 874 if (sgivwfb_device) {
875 ret = platform_device_add(sgivwfb_device);
876 } else
877 ret = -ENOMEM;
878 if (ret) {
885 driver_unregister(&sgivwfb_driver); 879 driver_unregister(&sgivwfb_driver);
880 platform_device_put(sgivwfb_device);
881 }
886 } 882 }
887 return ret; 883 return ret;
888} 884}
@@ -894,7 +890,7 @@ MODULE_LICENSE("GPL");
894 890
895static void __exit sgivwfb_exit(void) 891static void __exit sgivwfb_exit(void)
896{ 892{
897 platform_device_unregister(&sgivwfb_device); 893 platform_device_unregister(sgivwfb_device);
898 driver_unregister(&sgivwfb_driver); 894 driver_unregister(&sgivwfb_driver);
899} 895}
900 896