Skip to contentSkip to conversation

ASoC: Intel: Skylake: mem leak in skl register function

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: mem leak in skl register function

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

---
 sound/soc/intel/skylake/skl-pcm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/intel/skylake/skl-pcm.c +4 -1
index d0c02e8a6785..e2578ee001ff 100644
@@ -1462,6 +1462,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;
 		}
@@ -1474,8 +1475,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;
 }
Signature · 1 line
2.42.0.windows.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Kamil Duljas

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

---
  sound/soc/intel/skylake/skl-pcm.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/intel/skylake/skl-pcm.c +1 -0
index d0c02e8a6785..e2578ee001ff 100644
@@ -1462,6 +1462,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;
  		}
@@ -1474,8 +1475,10 @@ int skl_platform_register(struct device *dev)
 

sound/soc/intel/skylake/skl-pcm.c int skl_platform_register(struct device *dev) · line 1484

Quoted 10 lines
sound/soc/intel/skylake/skl-pcm.c +3 -1
  	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;
  }

Seems ok,

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

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

Applied to

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

Thanks!

[1/1] ASoC: Intel: Skylake: mem leak in skl register function

      commit: f8ba14b780273fd290ddf7ee0d7d7decb44cc365

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