public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: "Kamil Duljas" <kamil.duljas@gmail.com>,
	"Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Sasha Levin" <sashal@kernel.org>,
	cezary.rojewski@intel.com, pierre-louis.bossart@linux.intel.com,
	liam.r.girdwood@linux.intel.com, peter.ujfalusi@linux.intel.com,
	yung-chuan.liao@linux.intel.com,
	ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com,
	perex@perex.cz, tiwai@suse.com, zhangyiqun@phytium.com.cn,
	kuninori.morimoto.gx@renesas.com, suhui@nfschina.com,
	alsa-devel@alsa-project.org, linux-sound@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 03/12] ASoC: Intel: Skylake: mem leak in skl register function
Date: Mon, 11 Dec 2023 09:01:56 -0500	[thread overview]
Message-ID: <20231211140219.392379-3-sashal@kernel.org> (raw)
In-Reply-To: <20231211140219.392379-1-sashal@kernel.org>

From: Kamil Duljas <kamil.duljas@gmail.com>

[ Upstream commit f8ba14b780273fd290ddf7ee0d7d7decb44cc365 ]

skl_platform_register() uses krealloc. When krealloc is fail,
then previous memory is not freed. The leak is also when soc
component registration failed.

Signed-off-by: Kamil Duljas <kamil.duljas@gmail.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20231116224112.2209-2-kamil.duljas@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 sound/soc/intel/skylake/skl-pcm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 19176ae272742..3256f7c4eb747 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -1492,6 +1492,7 @@ int skl_platform_register(struct device *dev)
 		dais = krealloc(skl->dais, sizeof(skl_fe_dai) +
 				sizeof(skl_platform_dai), GFP_KERNEL);
 		if (!dais) {
+			kfree(skl->dais);
 			ret = -ENOMEM;
 			goto err;
 		}
@@ -1504,8 +1505,10 @@ int skl_platform_register(struct device *dev)
 
 	ret = devm_snd_soc_register_component(dev, &skl_component,
 					 skl->dais, num_dais);
-	if (ret)
+	if (ret) {
+		kfree(skl->dais);
 		dev_err(dev, "soc component registration failed %d\n", ret);
+	}
 err:
 	return ret;
 }
-- 
2.42.0


  parent reply	other threads:[~2023-12-11 14:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-11 14:01 [PATCH AUTOSEL 5.4 01/12] ASoC: Intel: Skylake: Fix mem leak in few functions Sasha Levin
2023-12-11 14:01 ` [PATCH AUTOSEL 5.4 02/12] ASoC: nau8822: Fix incorrect type in assignment and cast to restricted __be16 Sasha Levin
2023-12-11 14:01 ` Sasha Levin [this message]
2023-12-11 14:01 ` [PATCH AUTOSEL 5.4 04/12] ASoC: cs43130: Fix the position of const qualifier Sasha Levin
2023-12-11 14:01 ` [PATCH AUTOSEL 5.4 05/12] ASoC: cs43130: Fix incorrect frame delay configuration Sasha Levin
2023-12-11 14:01 ` [PATCH AUTOSEL 5.4 06/12] ASoC: rt5650: add mutex to avoid the jack detection failure Sasha Levin
2023-12-11 14:02 ` [PATCH AUTOSEL 5.4 07/12] nouveau/tu102: flush all pdbs on vmm flush Sasha Levin
2023-12-11 14:02 ` [PATCH AUTOSEL 5.4 08/12] net/tg3: fix race condition in tg3_reset_task() Sasha Levin
2023-12-11 14:02 ` [PATCH AUTOSEL 5.4 09/12] ASoC: da7219: Support low DC impedance headset Sasha Levin
2023-12-11 14:02 ` [PATCH AUTOSEL 5.4 10/12] nvme: introduce helper function to get ctrl state Sasha Levin
2023-12-11 14:02 ` [PATCH AUTOSEL 5.4 11/12] drm/exynos: fix a potential error pointer dereference Sasha Levin
2023-12-11 14:02 ` [PATCH AUTOSEL 5.4 12/12] drm/exynos: fix a wrong error checking Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231211140219.392379-3-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=kamil.duljas@gmail.com \
    --cc=kuninori.morimoto.gx@renesas.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --cc=suhui@nfschina.com \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.intel.com \
    --cc=zhangyiqun@phytium.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox