public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
	Kay Sievers <kay.sievers@vrfy.org>,
	James Simmons <jsimmons@infradead.org>
Subject: [PATCH 03/13] fbdev: fix race in device_create
Date: Tue, 20 May 2008 15:34:50 -0700	[thread overview]
Message-ID: <1211322900-12705-3-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20080520223237.GA12383@suse.de>

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


  parent reply	other threads:[~2008-05-20 22:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-20 22:32 [GIT PATCH] driver core fixes against 2.6.26-rc3 Greg KH
2008-05-20 22:34 ` [PATCH 01/13] Driver core: add device_create_vargs and device_create_drvdata Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 02/13] mm: bdi: fix race in bdi_class device creation Greg Kroah-Hartman
2008-05-20 22:34 ` Greg Kroah-Hartman [this message]
2008-05-20 22:34 ` [PATCH 04/13] ide: fix race in device_create Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 05/13] IB: " Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 06/13] LEDS: " Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 07/13] Power Supply: " Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 08/13] UIO: " Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 09/13] SOUND: " Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 10/13] s390: " Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 11/13] USB: Phidget: " Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 12/13] USB: Core: " Greg Kroah-Hartman
2008-05-20 22:35 ` [PATCH 13/13] SCSI: " Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1211322900-12705-3-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=jsimmons@infradead.org \
    --cc=kay.sievers@vrfy.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox