Skip to contentSkip to conversation

ASoC: Intel: Skylake: Fix mem leak in few functions

PATCH In review Kamil Duljas 3 participants 3 messages Nov 16, 2023 – Nov 17, 2023

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: Skylake: Fix mem leak in few functions

The resources should be freed when function return error.

---
 sound/soc/intel/skylake/skl-pcm.c     | 4 +++-
 sound/soc/intel/skylake/skl-sst-ipc.c | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +3 -1
index d0c02e8a6785..18866bc415a5 100644
@@ -240,8 +240,10 @@ static int skl_pcm_open(struct snd_pcm_substream *substream,
 	snd_pcm_set_sync(substream);
 
 	mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
-	if (!mconfig)
+	if (!mconfig) {
+		kfree(dma_params);
 		return -EINVAL;
+	}
 
 	skl_tplg_d0i3_get(skl, mconfig->d0i3_caps);
 
sound/soc/intel/skylake/skl-sst-ipc.c +3 -1
index 7a425271b08b..fd9624ad5f72 100644
@@ -1003,8 +1003,10 @@ int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
 
 	reply.size = (reply.header >> 32) & IPC_DATA_OFFSET_SZ_MASK;
 	buf = krealloc(reply.data, reply.size, GFP_KERNEL);
-	if (!buf)
+	if (!buf) {
+		kfree(reply.data);
 		return -ENOMEM;
+	}
 	*payload = buf;
 	*bytes = reply.size;
 
Signature · 1 line
2.35.2.windows.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 30 lines · Kamil Duljas

The resources should be freed when function return error.

---
  sound/soc/intel/skylake/skl-pcm.c     | 4 +++-
  sound/soc/intel/skylake/skl-sst-ipc.c | 4 +++-
  2 files changed, 6 insertions(+), 2 deletions(-)
sound/soc/intel/skylake/skl-pcm.c +3 -1
index d0c02e8a6785..18866bc415a5 100644
@@ -240,8 +240,10 @@ static int skl_pcm_open(struct snd_pcm_substream *substream,
  	snd_pcm_set_sync(substream);
 
  	mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
-	if (!mconfig)
+	if (!mconfig) {
+		kfree(dma_params);
  		return -EINVAL;
+	}
 
  	skl_tplg_d0i3_get(skl, mconfig->d0i3_caps);
 
sound/soc/intel/skylake/skl-sst-ipc.c +0 -0
index 7a425271b08b..fd9624ad5f72 100644
@@ -1003,8 +1003,10 @@ int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
 

sound/soc/intel/skylake/skl-sst-ipc.c int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, · line 1012

Quoted 10 lines
sound/soc/intel/skylake/skl-sst-ipc.c +3 -1
  	reply.size = (reply.header >> 32) & IPC_DATA_OFFSET_SZ_MASK;
  	buf = krealloc(reply.data, reply.size, GFP_KERNEL);
-	if (!buf)
+	if (!buf) {
+		kfree(reply.data);
  		return -ENOMEM;
+	}
  	*payload = buf;
  	*bytes = reply.size;
 

Seems ok,

maintainer
#2 lore raw
In reply to Kamil Duljas
Quoted 3 lines · Kamil Duljas

The resources should be freed when function return error.

Applied to

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

Thanks!

[1/1] ASoC: Intel: Skylake: Fix mem leak in few functions

      commit: d5c65be34df73fa01ed05611aafb73b440d89e29

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