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>,
	"Hans J. Koch" <hjk@linutronix.de>
Subject: [PATCH 08/13] UIO: fix race in device_create
Date: Tue, 20 May 2008 15:34:55 -0700	[thread overview]
Message-ID: <1211322900-12705-8-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: Hans J. Koch <hjk@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/uio/uio.c |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index 55cc7b8..0a12e90 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -649,15 +649,14 @@ int __uio_register_device(struct module *owner,
 	if (ret)
 		goto err_get_minor;
 
-	idev->dev = device_create(uio_class->class, parent,
-				  MKDEV(uio_major, idev->minor),
-				  "uio%d", idev->minor);
+	idev->dev = device_create_drvdata(uio_class->class, parent,
+					  MKDEV(uio_major, idev->minor), idev,
+					  "uio%d", idev->minor);
 	if (IS_ERR(idev->dev)) {
 		printk(KERN_ERR "UIO: device register failed\n");
 		ret = PTR_ERR(idev->dev);
 		goto err_device_create;
 	}
-	dev_set_drvdata(idev->dev, idev);
 
 	ret = uio_dev_add_attributes(idev);
 	if (ret)
-- 
1.5.5.1


  parent reply	other threads:[~2008-05-20 22:39 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 ` [PATCH 03/13] fbdev: fix race in device_create Greg Kroah-Hartman
2008-05-20 22:34 ` [PATCH 04/13] ide: " 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 ` Greg Kroah-Hartman [this message]
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-8-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=hjk@linutronix.de \
    --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