diff options
author | Karsten Wiese <fzu@wemgehoertderstaat.de> | 2007-01-31 04:05:30 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2007-02-09 03:03:24 -0500 |
commit | 8fa58af7db56077d6a042fd7b9dd4c9515e1c37b (patch) | |
tree | 759062886223b266c4200e8abab82789a9c5ba62 /sound/core/hwdep.c | |
parent | 298a2c753a5ae2f0e230a57e94843d248f0033e2 (diff) |
[ALSA] snd_hwdep_release() racefix
snd_card_file_remove() can free the snd_card.
Touch hw->* only before calling snd_card_file_remove().
Unrelated: Allow hwdep devices not to have own ops.release();
Signed-off-by: Karsten Wiese <fzu@wemgehoertderstaat.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/core/hwdep.c')
-rw-r--r-- | sound/core/hwdep.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index a6a6ad0ad3c8..39c03f3dfbfa 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c | |||
@@ -156,15 +156,16 @@ static int snd_hwdep_release(struct inode *inode, struct file * file) | |||
156 | int err = -ENXIO; | 156 | int err = -ENXIO; |
157 | struct snd_hwdep *hw = file->private_data; | 157 | struct snd_hwdep *hw = file->private_data; |
158 | struct module *mod = hw->card->module; | 158 | struct module *mod = hw->card->module; |
159 | |||
159 | mutex_lock(&hw->open_mutex); | 160 | mutex_lock(&hw->open_mutex); |
160 | if (hw->ops.release) { | 161 | if (hw->ops.release) |
161 | err = hw->ops.release(hw, file); | 162 | err = hw->ops.release(hw, file); |
162 | wake_up(&hw->open_wait); | ||
163 | } | ||
164 | if (hw->used > 0) | 163 | if (hw->used > 0) |
165 | hw->used--; | 164 | hw->used--; |
166 | snd_card_file_remove(hw->card, file); | ||
167 | mutex_unlock(&hw->open_mutex); | 165 | mutex_unlock(&hw->open_mutex); |
166 | wake_up(&hw->open_wait); | ||
167 | |||
168 | snd_card_file_remove(hw->card, file); | ||
168 | module_put(mod); | 169 | module_put(mod); |
169 | return err; | 170 | return err; |
170 | } | 171 | } |