alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] ASoC: intel: Fix memory leak in sst_media_open()
@ 2020-08-09 18:42 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2020-08-09 18:42 UTC (permalink / raw)
  To: Dinghao Liu, alsa-devel
  Cc: Cezary Rojewski, Kuninori Morimoto, kernel-janitors, Jie Yang,
	Takashi Iwai, Kangjie Lu, linux-kernel, Pierre-Louis Bossart,
	Liam Girdwood, Vinod Koul, Mark Brown, Ranjani Sridharan,
	Subhransu S. Prusty

> When power_up_sst() fails, stream needs to be freed
> just like when try_module_get() fails. However, current
> code is returning directly and ends up leaking memory.

Would an imperative wording be preferred for the change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=06a81c1c7db9bd5de0bd38cd5acc44bb22b99150#n151> +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c
> @@ -330,8 +330,10 @@  static int sst_media_open(struct snd_pcm_substream *substream,
>  	runtime->private_data = stream;
>
>  	ret_val = power_up_sst(stream);
> -	if (ret_val < 0)
> +	if (ret_val < 0) {
> +		kfree(stream);
>  		return ret_val;
> +	}
…

I propose to add a jump target so that a bit of common exception handling code
can be better reused at the end of this function implementation.

Regards,
Markus

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-08-09 18:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-09 18:42 [PATCH] ASoC: intel: Fix memory leak in sst_media_open() Markus Elfring

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).