]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
ALSA: fix possible memory leak in snd_mixer_oss_build_input()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Sun, 2 Sep 2012 14:10:27 +0000 (22:10 +0800)
committerTakashi Iwai <tiwai@suse.de>
Mon, 3 Sep 2012 08:08:28 +0000 (10:08 +0200)
uinfo has been allocated in this function and should be
freed before leaving from the error handling cases.

spatch with a semantic match is used to found this problem.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/oss/mixer_oss.c

index 18297f7f2c55825ed8fe7737a965d271ad6f30dc..29f6ded02555568498473fb37547c9e7b0b96c2b 100644 (file)
@@ -1046,6 +1046,7 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mix
                        
                if (kctl->info(kctl, uinfo)) {
                        up_read(&mixer->card->controls_rwsem);
+                       kfree(uinfo);
                        return 0;
                }
                strcpy(str, ptr->name);
@@ -1061,6 +1062,7 @@ static int snd_mixer_oss_build_input(struct snd_mixer_oss *mixer, struct snd_mix
                                uinfo->value.enumerated.item = slot.capture_item;
                                if (kctl->info(kctl, uinfo)) {
                                        up_read(&mixer->card->controls_rwsem);
+                                       kfree(uinfo);
                                        return 0;
                                }
                                if (!strcmp(uinfo->value.enumerated.name, str)) {