linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] ASoC: SOF: topology: Fix memory leak in sof_control_load()
@ 2022-03-18  2:16 Yu Liao
  2022-04-08 11:24 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Yu Liao @ 2022-03-18  2:16 UTC (permalink / raw)
  To: linux-kernel, ranjani.sridharan; +Cc: broonie, liaoyu15, liwei391

scontrol doesn't get freed when kstrdup returns NULL.
Fix by free iscontrol in that case.

     scontrol = kzalloc(sizeof(*scontrol), GFP_KERNEL);
     if (!scontrol)
         return -ENOMEM;

     scontrol->name = kstrdup(hdr->name, GFP_KERNEL);
     if (!scontrol->name)
         return -ENOMEM;

Signed-off-by: Yu Liao <liaoyu15@huawei.com>
---
 sound/soc/sof/topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index 367fbe2d5b31..88f34f43d693 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -905,8 +905,10 @@ static int sof_control_load(struct snd_soc_component *scomp, int index,
 		return -ENOMEM;
 
 	scontrol->name = kstrdup(hdr->name, GFP_KERNEL);
-	if (!scontrol->name)
+	if (!scontrol->name) {
+		kfree(scontrol);
 		return -ENOMEM;
+	}
 
 	scontrol->scomp = scomp;
 	scontrol->access = kc->access;
-- 
2.25.1


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

* Re: [PATCH -next] ASoC: SOF: topology: Fix memory leak in sof_control_load()
  2022-03-18  2:16 [PATCH -next] ASoC: SOF: topology: Fix memory leak in sof_control_load() Yu Liao
@ 2022-04-08 11:24 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2022-04-08 11:24 UTC (permalink / raw)
  To: ranjani.sridharan, liaoyu15, linux-kernel; +Cc: liwei391

On Fri, 18 Mar 2022 10:16:16 +0800, Yu Liao wrote:
> scontrol doesn't get freed when kstrdup returns NULL.
> Fix by free iscontrol in that case.
> 
>      scontrol = kzalloc(sizeof(*scontrol), GFP_KERNEL);
>      if (!scontrol)
>          return -ENOMEM;
> 
> [...]

Applied to

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

Thanks!

[1/1] ASoC: SOF: topology: Fix memory leak in sof_control_load()
      commit: 9b91d0ece22b9ab37fc185511c7f992e51c93d6e

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

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

end of thread, other threads:[~2022-04-08 11:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-18  2:16 [PATCH -next] ASoC: SOF: topology: Fix memory leak in sof_control_load() Yu Liao
2022-04-08 11:24 ` 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).