linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ALSA: fix possible memory leak in snd_mixer_oss_build_input()
@ 2012-09-02 14:10 Wei Yongjun
  2012-09-03  8:15 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2012-09-02 14:10 UTC (permalink / raw)
  To: perex, tiwai; +Cc: yongjun_wei, alsa-devel, linux-kernel

From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

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>
---
 sound/core/oss/mixer_oss.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
index 18297f7..29f6ded 100644
--- a/sound/core/oss/mixer_oss.c
+++ b/sound/core/oss/mixer_oss.c
@@ -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)) {



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: fix possible memory leak in snd_mixer_oss_build_input()
  2012-09-02 14:10 [PATCH] ALSA: fix possible memory leak in snd_mixer_oss_build_input() Wei Yongjun
@ 2012-09-03  8:15 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2012-09-03  8:15 UTC (permalink / raw)
  To: Wei Yongjun; +Cc: perex, yongjun_wei, alsa-devel, linux-kernel

At Sun, 2 Sep 2012 22:10:27 +0800,
Wei Yongjun wrote:
> 
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> 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>

Applied now.  Thanks.


Takashi

> ---
>  sound/core/oss/mixer_oss.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sound/core/oss/mixer_oss.c b/sound/core/oss/mixer_oss.c
> index 18297f7..29f6ded 100644
> --- a/sound/core/oss/mixer_oss.c
> +++ b/sound/core/oss/mixer_oss.c
> @@ -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)) {
> 
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-09-03  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-02 14:10 [PATCH] ALSA: fix possible memory leak in snd_mixer_oss_build_input() Wei Yongjun
2012-09-03  8:15 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).