linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data
@ 2019-10-27 21:53 Navid Emamdoost
  2019-10-28  2:15 ` Pierre-Louis Bossart
  2019-10-28 14:56 ` Applied "ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data" to the asoc tree Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Navid Emamdoost @ 2019-10-27 21:53 UTC (permalink / raw)
  Cc: emamd001, kjlu, smccaman, Navid Emamdoost, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, Pierre-Louis Bossart,
	Guennadi Liakhovetski, Ranjani Sridharan, Pan Xiuli,
	Kai Vehmanen, Slawomir Blauciak, alsa-devel, linux-kernel

In the implementation of sof_set_get_large_ctrl_data() there is a memory
leak in case an error. Release partdata if sof_get_ctrl_copy_params()
fails.

Fixes: 54d198d5019d ("ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
 sound/soc/sof/ipc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
index b2f359d2f7e5..086eeeab8679 100644
--- a/sound/soc/sof/ipc.c
+++ b/sound/soc/sof/ipc.c
@@ -572,8 +572,10 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
 	else
 		err = sof_get_ctrl_copy_params(cdata->type, partdata, cdata,
 					       sparams);
-	if (err < 0)
+	if (err < 0) {
+		kfree(partdata);
 		return err;
+	}
 
 	msg_bytes = sparams->msg_bytes;
 	pl_size = sparams->pl_size;
-- 
2.17.1


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

* Re: [PATCH] ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data
  2019-10-27 21:53 [PATCH] ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data Navid Emamdoost
@ 2019-10-28  2:15 ` Pierre-Louis Bossart
  2019-10-28 16:35   ` Navid Emamdoost
  2019-10-28 14:56 ` Applied "ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data" to the asoc tree Mark Brown
  1 sibling, 1 reply; 4+ messages in thread
From: Pierre-Louis Bossart @ 2019-10-28  2:15 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: emamd001, kjlu, smccaman, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, Guennadi Liakhovetski,
	Ranjani Sridharan, Pan Xiuli, Kai Vehmanen, Slawomir Blauciak,
	alsa-devel, linux-kernel



On 10/27/19 4:53 PM, Navid Emamdoost wrote:
> In the implementation of sof_set_get_large_ctrl_data() there is a memory
> leak in case an error. Release partdata if sof_get_ctrl_copy_params()
> fails.
> 
> Fixes: 54d198d5019d ("ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly")
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>

Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>

May I ask which tool you used to find those issues, looks like we have a 
gap here?

> ---
>   sound/soc/sof/ipc.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
> index b2f359d2f7e5..086eeeab8679 100644
> --- a/sound/soc/sof/ipc.c
> +++ b/sound/soc/sof/ipc.c
> @@ -572,8 +572,10 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
>   	else
>   		err = sof_get_ctrl_copy_params(cdata->type, partdata, cdata,
>   					       sparams);
> -	if (err < 0)
> +	if (err < 0) {
> +		kfree(partdata);
>   		return err;
> +	}
>   
>   	msg_bytes = sparams->msg_bytes;
>   	pl_size = sparams->pl_size;
> 

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

* Applied "ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data" to the asoc tree
  2019-10-27 21:53 [PATCH] ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data Navid Emamdoost
  2019-10-28  2:15 ` Pierre-Louis Bossart
@ 2019-10-28 14:56 ` Mark Brown
  1 sibling, 0 replies; 4+ messages in thread
From: Mark Brown @ 2019-10-28 14:56 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: alsa-devel, Cc:, Cc:,
	emamd001, Guennadi Liakhovetski, Jaroslav Kysela, Kai Vehmanen,
	kjlu, Liam Girdwood, linux-kernel, Mark Brown, Pan Xiuli,
	Pierre-Louis Bossart, Ranjani Sridharan, Slawomir Blauciak,
	smccaman, Takashi Iwai

The patch

   ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.4

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

From 45c1380358b12bf2d1db20a5874e9544f56b34ab Mon Sep 17 00:00:00 2001
From: Navid Emamdoost <navid.emamdoost@gmail.com>
Date: Sun, 27 Oct 2019 16:53:24 -0500
Subject: [PATCH] ASoC: SOF: ipc: Fix memory leak in
 sof_set_get_large_ctrl_data

In the implementation of sof_set_get_large_ctrl_data() there is a memory
leak in case an error. Release partdata if sof_get_ctrl_copy_params()
fails.

Fixes: 54d198d5019d ("ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Link: https://lore.kernel.org/r/20191027215330.12729-1-navid.emamdoost@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/sof/ipc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
index b2f359d2f7e5..086eeeab8679 100644
--- a/sound/soc/sof/ipc.c
+++ b/sound/soc/sof/ipc.c
@@ -572,8 +572,10 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
 	else
 		err = sof_get_ctrl_copy_params(cdata->type, partdata, cdata,
 					       sparams);
-	if (err < 0)
+	if (err < 0) {
+		kfree(partdata);
 		return err;
+	}
 
 	msg_bytes = sparams->msg_bytes;
 	pl_size = sparams->pl_size;
-- 
2.20.1


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

* Re: [PATCH] ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data
  2019-10-28  2:15 ` Pierre-Louis Bossart
@ 2019-10-28 16:35   ` Navid Emamdoost
  0 siblings, 0 replies; 4+ messages in thread
From: Navid Emamdoost @ 2019-10-28 16:35 UTC (permalink / raw)
  To: Pierre-Louis Bossart
  Cc: Navid Emamdoost, Kangjie Lu, Stephen McCamant, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai, Guennadi Liakhovetski,
	Ranjani Sridharan, Pan Xiuli, Kai Vehmanen, Slawomir Blauciak,
	alsa-devel, LKML

On Sun, Oct 27, 2019 at 9:15 PM Pierre-Louis Bossart
<pierre-louis.bossart@linux.intel.com> wrote:
>
>
>
> On 10/27/19 4:53 PM, Navid Emamdoost wrote:
> > In the implementation of sof_set_get_large_ctrl_data() there is a memory
> > leak in case an error. Release partdata if sof_get_ctrl_copy_params()
> > fails.
> >
> > Fixes: 54d198d5019d ("ASoC: SOF: Propagate sof_get_ctrl_copy_params() error properly")
> > Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
>
> Acked-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
>
> May I ask which tool you used to find those issues, looks like we have a
> gap here?

We are developing a research tool to find such cases. Not sure what
gap you are referring to, but we statically track the allocation and
look for an appropriate release/assignment of the pointer.


>
> > ---
> >   sound/soc/sof/ipc.c | 4 +++-
> >   1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c
> > index b2f359d2f7e5..086eeeab8679 100644
> > --- a/sound/soc/sof/ipc.c
> > +++ b/sound/soc/sof/ipc.c
> > @@ -572,8 +572,10 @@ static int sof_set_get_large_ctrl_data(struct snd_sof_dev *sdev,
> >       else
> >               err = sof_get_ctrl_copy_params(cdata->type, partdata, cdata,
> >                                              sparams);
> > -     if (err < 0)
> > +     if (err < 0) {
> > +             kfree(partdata);
> >               return err;
> > +     }
> >
> >       msg_bytes = sparams->msg_bytes;
> >       pl_size = sparams->pl_size;
> >



--
Navid.

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

end of thread, other threads:[~2019-10-28 16:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-27 21:53 [PATCH] ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data Navid Emamdoost
2019-10-28  2:15 ` Pierre-Louis Bossart
2019-10-28 16:35   ` Navid Emamdoost
2019-10-28 14:56 ` Applied "ASoC: SOF: ipc: Fix memory leak in sof_set_get_large_ctrl_data" to the asoc tree Mark Brown

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