Skip to content

Commit

Permalink
[ALSA] snd_hwdep_release() racefix
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Karsten Wiese authored and Jaroslav Kysela committed Feb 9, 2007
1 parent 298a2c7 commit 8fa58af
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions sound/core/hwdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,16 @@ static int snd_hwdep_release(struct inode *inode, struct file * file)
int err = -ENXIO;
struct snd_hwdep *hw = file->private_data;
struct module *mod = hw->card->module;

mutex_lock(&hw->open_mutex);
if (hw->ops.release) {
if (hw->ops.release)
err = hw->ops.release(hw, file);
wake_up(&hw->open_wait);
}
if (hw->used > 0)
hw->used--;
snd_card_file_remove(hw->card, file);
mutex_unlock(&hw->open_mutex);
wake_up(&hw->open_wait);

snd_card_file_remove(hw->card, file);
module_put(mod);
return err;
}
Expand Down

0 comments on commit 8fa58af

Please sign in to comment.