ALSA: OSS mixer emulation - fix locking

Fix mutex release and cleanup some locking code.

Cc: <stable@kernel.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2010-10-08 10:48:50 +02:00
Родитель b1c73fc8e6
Коммит 838c364ff0
1 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -618,8 +618,10 @@ static void snd_mixer_oss_put_volume1_vol(struct snd_mixer_oss_file *fmixer,
if (numid == ID_UNKNOWN) if (numid == ID_UNKNOWN)
return; return;
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) {
up_read(&card->controls_rwsem);
return; return;
}
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
if (uinfo == NULL || uctl == NULL) if (uinfo == NULL || uctl == NULL)
@ -658,7 +660,7 @@ static void snd_mixer_oss_put_volume1_sw(struct snd_mixer_oss_file *fmixer,
return; return;
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) { if ((kctl = snd_ctl_find_numid(card, numid)) == NULL) {
up_read(&fmixer->card->controls_rwsem); up_read(&card->controls_rwsem);
return; return;
} }
uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL); uinfo = kzalloc(sizeof(*uinfo), GFP_KERNEL);
@ -797,7 +799,7 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
if (uinfo == NULL || uctl == NULL) { if (uinfo == NULL || uctl == NULL) {
err = -ENOMEM; err = -ENOMEM;
goto __unlock; goto __free_only;
} }
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0); kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
@ -826,6 +828,7 @@ static int snd_mixer_oss_get_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
err = 0; err = 0;
__unlock: __unlock:
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
__free_only:
kfree(uctl); kfree(uctl);
kfree(uinfo); kfree(uinfo);
return err; return err;
@ -847,7 +850,7 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
uctl = kzalloc(sizeof(*uctl), GFP_KERNEL); uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
if (uinfo == NULL || uctl == NULL) { if (uinfo == NULL || uctl == NULL) {
err = -ENOMEM; err = -ENOMEM;
goto __unlock; goto __free_only;
} }
down_read(&card->controls_rwsem); down_read(&card->controls_rwsem);
kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0); kctl = snd_mixer_oss_test_id(mixer, "Capture Source", 0);
@ -880,6 +883,7 @@ static int snd_mixer_oss_put_recsrc2(struct snd_mixer_oss_file *fmixer, unsigned
err = 0; err = 0;
__unlock: __unlock:
up_read(&card->controls_rwsem); up_read(&card->controls_rwsem);
__free_only:
kfree(uctl); kfree(uctl);
kfree(uinfo); kfree(uinfo);
return err; return err;