diff options
author | Takashi Iwai <tiwai@suse.de> | 2012-11-07 12:44:12 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-11-17 13:14:22 -0800 |
commit | 40edba667959559aa4385a5ec047420fcfeb5f03 (patch) | |
tree | 6df9fc6d71f5d7608a95ca7d437fca00b83afb1f /sound/core/hwdep.c | |
parent | fb434cc26173c2285d48d640c639493bc6a6c5f5 (diff) |
ALSA: Add a reference counter to card instance
commit a0830dbd4e42b38aefdf3fb61ba5019a1a99ea85 upstream.
For more strict protection for wild disconnections, a refcount is
introduced to the card instance, and let it up/down when an object is
referred via snd_lookup_*() in the open ops.
The free-after-last-close check is also changed to check this refcount
instead of the empty list, too.
Reported-by: Matthieu CASTET <matthieu.castet@parrot.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'sound/core/hwdep.c')
-rw-r--r-- | sound/core/hwdep.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index a70ee7f1ed9..dbc3556bae3 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -99,8 +99,10 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) if (hw == NULL) return -ENODEV; - if (!try_module_get(hw->card->module)) + if (!try_module_get(hw->card->module)) { + snd_card_unref(hw->card); return -EFAULT; + } init_waitqueue_entry(&wait, current); add_wait_queue(&hw->open_wait, &wait); @@ -147,6 +149,7 @@ static int snd_hwdep_open(struct inode *inode, struct file * file) mutex_unlock(&hw->open_mutex); if (err < 0) module_put(hw->card->module); + snd_card_unref(hw->card); return err; } |