Skip to contentSkip to conversation

ASoC: Intel: Skylake: prevent memory leak in snd_skl_parse_uuids

PATCH Superseded Navid Emamdoost 2 participants 2 messages Sep 25, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: Intel: Skylake: prevent memory leak in snd_skl_parse_uuids

In snd_skl_parse_uuids if allocation for module->instance_id fails, the allocated memory for module shoulde be released.

---
 sound/soc/intel/skylake/skl-sst-utils.c | 1 +
 1 file changed, 1 insertion(+)
sound/soc/intel/skylake/skl-sst-utils.c +1 -0
index d43cbf4a71ef..d4db64d72b2c 100644
@@ -299,6 +299,7 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
 		module->instance_id = devm_kzalloc(ctx->dev, size, GFP_KERNEL);
 		if (!module->instance_id) {
 			ret = -ENOMEM;
+			kfree(module);
 			goto free_uuid_list;
 		}
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 2 lines · Navid Emamdoost

In snd_skl_parse_uuids if allocation for module->instance_id fails, the allocated memory for module shoulde be released.

Since it's using devm_*() for the second allocation it would be cleaner to either switch it to regular kcalloc() or to switch the first one to devm_kzalloc(), whatever suits better.

Quoted 4 lines
sound/soc/intel/skylake/skl-sst-utils.c +1 -0
 		module->instance_id = devm_kzalloc(ctx->dev, size, GFP_KERNEL);
 		if (!module->instance_id) {
 
+			kfree(module);
Signature · 2 lines
With Best Regards,
Andy Shevchenko