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 | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/video/display/display-sysfs.c b/drivers/video/display/display-sysfs.c
index 3547717..6ef800b 100644
--- a/drivers/video/display/display-sysfs.c
+++ b/drivers/video/display/display-sysfs.c
@@ -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);
--
1.5.5.1
--
| Dmitry Torokhov | 2.6.27-rc8+ - first impressions |
| Linus Torvalds | Linux 2.6.27-rc8 |
| Nick Piggin | [patch 3/6] mm: fix fault vs invalidate race for linear mappings |
| Alan Cox | [PATCH 00/76] Queued TTY Patches |
git: | |
| Petr Baudis | [FYI][PATCH] Customizing the WinGit installer |
| Pierre Habouzit | Re: git push (mis ?)behavior |
| Mark Levedahl | Allowing override of the default "origin" nickname |
| Junio C Hamano | [PATCH] Detached HEAD (experimental) |
| Richard Stallman | Real men don't attack straw men |
| Luca Dell'Oca | Authenticate squid in Active Directory |
| Leon Dippenaar | New tcp stack attack |
| Nuno Magalhães | Can't scp, ssh is slow to authenticate. |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| KOSAKI Motohiro | [bug?] tg3: Failed to load firmware "tigon/tg3_tso.bin" |
| Andi Kleen | Re: [PATCH] Disable TSO for non standard qdiscs |
| Alexey Dobriyan | [PATCH 01/33] nf_conntrack_sip: de-static helper pointers |
