Skip to content

Commit

Permalink
[DRIVER MODEL] Fix arcfb
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Russell King authored and Russell King committed Nov 5, 2005
1 parent 09c6518 commit 8d972a9
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions drivers/video/arcfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,6 @@ static ssize_t arcfb_write(struct file *file, const char *buf, size_t count,
return err;
}

static void arcfb_platform_release(struct device *device)
{
}

static struct fb_ops arcfb_ops = {
.owner = THIS_MODULE,
.fb_open = arcfb_open,
Expand Down Expand Up @@ -624,13 +620,7 @@ static struct device_driver arcfb_driver = {
.remove = arcfb_remove,
};

static struct platform_device arcfb_device = {
.name = "arcfb",
.id = 0,
.dev = {
.release = arcfb_platform_release,
}
};
static struct platform_device *arcfb_device;

static int __init arcfb_init(void)
{
Expand All @@ -641,17 +631,24 @@ static int __init arcfb_init(void)

ret = driver_register(&arcfb_driver);
if (!ret) {
ret = platform_device_register(&arcfb_device);
if (ret)
arcfb_device = platform_device_alloc("arcfb", 0);
if (arcfb_device) {
ret = platform_device_add(arcfb_device);
} else {
ret = -ENOMEM;
}
if (ret) {
platform_device_put(arcfb_device);
driver_unregister(&arcfb_driver);
}
}
return ret;

}

static void __exit arcfb_exit(void)
{
platform_device_unregister(&arcfb_device);
platform_device_unregister(arcfb_device);
driver_unregister(&arcfb_driver);
}

Expand Down

0 comments on commit 8d972a9

Please sign in to comment.