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>,
Richard Purdie <rpurdie@rpsys.net>
Subject: [PATCH 06/13] LEDS: fix race in device_create
Date: Tue, 20 May 2008 15:34:53 -0700 [thread overview]
Message-ID: <1211322900-12705-6-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: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/leds/led-class.c | 6 ++----
1 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/leds/led-class.c b/drivers/leds/led-class.c
index b3c54be..559a408 100644
--- a/drivers/leds/led-class.c
+++ b/drivers/leds/led-class.c
@@ -103,13 +103,11 @@ int led_classdev_register(struct device *parent, struct led_classdev *led_cdev)
{
int rc;
- led_cdev->dev = device_create(leds_class, parent, 0, "%s",
- led_cdev->name);
+ led_cdev->dev = device_create_drvdata(leds_class, parent, 0, led_cdev,
+ "%s", led_cdev->name);
if (IS_ERR(led_cdev->dev))
return PTR_ERR(led_cdev->dev);
- dev_set_drvdata(led_cdev->dev, led_cdev);
-
/* register the attributes */
rc = device_create_file(led_cdev->dev, &dev_attr_brightness);
if (rc)
--
1.5.5.1
next prev parent reply other threads:[~2008-05-20 22:38 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 ` Greg Kroah-Hartman [this message]
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-6-git-send-email-gregkh@suse.de \
--to=gregkh@suse.de \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rpurdie@rpsys.net \
/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