linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sound: synth: emux: soundfont.c:  Cleaning up memory leak
@ 2014-06-01 11:35 Rickard Strandqvist
  2014-06-01 12:35 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Rickard Strandqvist @ 2014-06-01 11:35 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai
  Cc: Rickard Strandqvist, alsa-devel, linux-kernel

There is a risk for memory leak in when something unexpected happens
and the function returns.

This was largely found by using a static code analysis program called cppcheck.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 sound/synth/emux/soundfont.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
index 1137b85..09c5eeb 100644
--- a/sound/synth/emux/soundfont.c
+++ b/sound/synth/emux/soundfont.c
@@ -1021,6 +1021,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data,
 			 data, count);
 		if (rc < 0) {
 			sf_sample_delete(sflist, sf, smp);
+			free(zone);
 			return rc;
 		}
 		/* memory offset is updated after */
-- 
1.7.10.4


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

* Re: [PATCH] sound: synth: emux: soundfont.c:  Cleaning up memory leak
  2014-06-01 11:35 [PATCH] sound: synth: emux: soundfont.c: Cleaning up memory leak Rickard Strandqvist
@ 2014-06-01 12:35 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2014-06-01 12:35 UTC (permalink / raw)
  To: Rickard Strandqvist; +Cc: Jaroslav Kysela, alsa-devel, linux-kernel

At Sun,  1 Jun 2014 13:35:24 +0200,
Rickard Strandqvist wrote:
> 
> There is a risk for memory leak in when something unexpected happens
> and the function returns.
> 
> This was largely found by using a static code analysis program called cppcheck.
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  sound/synth/emux/soundfont.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sound/synth/emux/soundfont.c b/sound/synth/emux/soundfont.c
> index 1137b85..09c5eeb 100644
> --- a/sound/synth/emux/soundfont.c
> +++ b/sound/synth/emux/soundfont.c
> @@ -1021,6 +1021,7 @@ load_guspatch(struct snd_sf_list *sflist, const char __user *data,
>  			 data, count);
>  		if (rc < 0) {
>  			sf_sample_delete(sflist, sf, smp);
> +			free(zone);

I applied the patch with the correction of a typo (it must be
kfree()).  At the next time, please compile-test at least :)


thanks,

Takashi

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

end of thread, other threads:[~2014-06-01 12:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-01 11:35 [PATCH] sound: synth: emux: soundfont.c: Cleaning up memory leak Rickard Strandqvist
2014-06-01 12:35 ` 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).