aboutsummaryrefslogtreecommitdiffstats
path: root/sound/core
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2008-05-16 20:55:12 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-05-20 16:31:55 -0400
commit5d99a8b814abd76e89ef2cf90e29bbb879d6d66c (patch)
tree6ff4df159debb0e990f6ff1eabdf12ff8c4b0ce2 /sound/core
parent43691da4cefcf0d0dd6432f9e7e0dba902b59597 (diff)
SOUND: fix race in device_create
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: Jaroslav Kysela <perex@perex.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'sound/core')
-rw-r--r--sound/core/sound.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/sound/core/sound.c b/sound/core/sound.c
index 812f91b3de5b..6c8ab48c689a 100644
--- a/sound/core/sound.c
+++ b/sound/core/sound.c
@@ -259,8 +259,9 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
259 return minor; 259 return minor;
260 } 260 }
261 snd_minors[minor] = preg; 261 snd_minors[minor] = preg;
262 preg->dev = device_create(sound_class, device, MKDEV(major, minor), 262 preg->dev = device_create_drvdata(sound_class, device,
263 "%s", name); 263 MKDEV(major, minor),
264 private_data, "%s", name);
264 if (IS_ERR(preg->dev)) { 265 if (IS_ERR(preg->dev)) {
265 snd_minors[minor] = NULL; 266 snd_minors[minor] = NULL;
266 mutex_unlock(&sound_mutex); 267 mutex_unlock(&sound_mutex);
@@ -269,9 +270,6 @@ int snd_register_device_for_dev(int type, struct snd_card *card, int dev,
269 return minor; 270 return minor;
270 } 271 }
271 272
272 if (preg->dev)
273 dev_set_drvdata(preg->dev, private_data);
274
275 mutex_unlock(&sound_mutex); 273 mutex_unlock(&sound_mutex);
276 return 0; 274 return 0;
277} 275}