login
Header Space

 
 

[PATCH 04/13] ide: fix race in device_create

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <linux-kernel@...>
Cc: Greg Kroah-Hartman <gregkh@...>, Kay Sievers <kay.sievers@...>
Date: Tuesday, May 20, 2008 - 6:34 pm

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>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/ide/ide-probe.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c
index 34b0d4f..655ec7e 100644
--- a/drivers/ide/ide-probe.c
+++ b/drivers/ide/ide-probe.c
@@ -648,13 +648,12 @@ static int ide_register_port(ide_hwif_t *hwif)
 
 	get_device(&hwif->gendev);
 
-	hwif->portdev = device_create(ide_port_class, &hwif->gendev,
-				      MKDEV(0, 0), hwif->name);
+	hwif->portdev = device_create_drvdata(ide_port_class, &hwif->gendev,
+					      MKDEV(0, 0), hwif, hwif->name);
 	if (IS_ERR(hwif->portdev)) {
 		ret = PTR_ERR(hwif->portdev);
 		device_unregister(&hwif->gendev);
 	}
-	dev_set_drvdata(hwif->portdev, hwif);
 out:
 	return ret;
 }
-- 
1.5.5.1

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PATCH] driver core fixes against 2.6.26-rc3, Greg KH, (Tue May 20, 6:32 pm)
[PATCH 13/13] SCSI: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:35 pm)
[PATCH 12/13] USB: Core: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 11/13] USB: Phidget: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 10/13] s390: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 09/13] SOUND: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 08/13] UIO: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 07/13] Power Supply: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 06/13] LEDS: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 05/13] IB: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 03/13] fbdev: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 04/13] ide: fix race in device_create, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 02/13] mm: bdi: fix race in bdi_class device creation, Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
[PATCH 01/13] Driver core: add device_create_vargs and devic..., Greg Kroah-Hartman, (Tue May 20, 6:34 pm)
speck-geostationary