]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
fbdev: fix race in device_create
authorGreg Kroah-Hartman <gregkh@suse.de>
Thu, 15 May 2008 20:44:08 +0000 (13:44 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 20 May 2008 20:31:53 +0000 (13:31 -0700)
There is a race from when a device is created with device_create() and
then the drvdata is set with a call to dev_set_drvdata() in which a
sysfs file could be open, yet the drvdata will be NULL, causing all
sorts of bad things to happen.

This patch fixes the problem by using the new function,
device_create_drvdata().

Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/video/display/display-sysfs.c

index 35477177bef472bae656141e590581c62b41e11e..6ef800bdf4822f4fcf09f4e0e9db002b0d6fb9ba 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/ctype.h>
 #include <linux/idr.h>
 #include <linux/err.h>
+#include <linux/kdev_t.h>
 
 static ssize_t display_show_name(struct device *dev,
                                struct device_attribute *attr, char *buf)
@@ -152,10 +153,13 @@ struct display_device *display_device_register(struct display_driver *driver,
                mutex_unlock(&allocated_dsp_lock);
 
                if (!ret) {
-                       new_dev->dev = device_create(display_class, parent, 0,
-                                               "display%d", new_dev->idx);
+                       new_dev->dev = device_create_drvdata(display_class,
+                                                            parent,
+                                                            MKDEV(0,0),
+                                                            new_dev,
+                                                            "display%d",
+                                                            new_dev->idx);
                        if (!IS_ERR(new_dev->dev)) {
-                               dev_set_drvdata(new_dev->dev, new_dev);
                                new_dev->parent = parent;
                                new_dev->driver = driver;
                                mutex_init(&new_dev->lock);