aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2005-11-05 16:21:38 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2005-11-05 16:21:38 -0500
commit8d972a962177a261fc894f767fa3014f63d661e9 (patch)
treece79f869f65da3ce87c0ad50f7a84d527511d61f /drivers/video
parent09c6518ca0de24549a923891b2d335e8496d79a9 (diff)
[DRIVER MODEL] Fix arcfb
Release code in driver modules 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 text will be freed. Subsequently, when the last reference is dropped, the release code will be called, which no longer exists. 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>
Diffstat (limited to 'drivers/video')
-rw-r--r--drivers/video/arcfb.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
index 126daff1c848..6aa9f824c185 100644
--- a/drivers/video/arcfb.c
+++ b/drivers/video/arcfb.c
@@ -502,10 +502,6 @@ static ssize_t arcfb_write(struct file *file, const char *buf, size_t count,
502 return err; 502 return err;
503} 503}
504 504
505static void arcfb_platform_release(struct device *device)
506{
507}
508
509static struct fb_ops arcfb_ops = { 505static struct fb_ops arcfb_ops = {
510 .owner = THIS_MODULE, 506 .owner = THIS_MODULE,
511 .fb_open = arcfb_open, 507 .fb_open = arcfb_open,
@@ -624,13 +620,7 @@ static struct device_driver arcfb_driver = {
624 .remove = arcfb_remove, 620 .remove = arcfb_remove,
625}; 621};
626 622
627static struct platform_device arcfb_device = { 623static struct platform_device *arcfb_device;
628 .name = "arcfb",
629 .id = 0,
630 .dev = {
631 .release = arcfb_platform_release,
632 }
633};
634 624
635static int __init arcfb_init(void) 625static int __init arcfb_init(void)
636{ 626{
@@ -641,9 +631,16 @@ static int __init arcfb_init(void)
641 631
642 ret = driver_register(&arcfb_driver); 632 ret = driver_register(&arcfb_driver);
643 if (!ret) { 633 if (!ret) {
644 ret = platform_device_register(&arcfb_device); 634 arcfb_device = platform_device_alloc("arcfb", 0);
645 if (ret) 635 if (arcfb_device) {
636 ret = platform_device_add(arcfb_device);
637 } else {
638 ret = -ENOMEM;
639 }
640 if (ret) {
641 platform_device_put(arcfb_device);
646 driver_unregister(&arcfb_driver); 642 driver_unregister(&arcfb_driver);
643 }
647 } 644 }
648 return ret; 645 return ret;
649 646
@@ -651,7 +648,7 @@ static int __init arcfb_init(void)
651 648
652static void __exit arcfb_exit(void) 649static void __exit arcfb_exit(void)
653{ 650{
654 platform_device_unregister(&arcfb_device); 651 platform_device_unregister(arcfb_device);
655 driver_unregister(&arcfb_driver); 652 driver_unregister(&arcfb_driver);
656} 653}
657 654