Commit f8e06652 authored by Pankaj Bharadiya's avatar Pankaj Bharadiya Committed by Mark Brown

ASoC: Intel: Skylake: Fix uuid_module memory leak in failure case

In the loop that adds the uuid_module to the uuid_list list, allocated
memory is not properly freed in the error path free uuid_list whenever
any of the memory allocation in the loop fails to avoid memory leak.
Signed-off-by: default avatarPankaj Bharadiya <pankaj.laxminarayan.bharadiya@intel.com>
Signed-off-by: default avatarGuneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: default avatarVinod Koul <vinod.koul@intel.com>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent 0265ddd7
...@@ -251,6 +251,7 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw, ...@@ -251,6 +251,7 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
struct uuid_module *module; struct uuid_module *module;
struct firmware stripped_fw; struct firmware stripped_fw;
unsigned int safe_file; unsigned int safe_file;
int ret = 0;
/* Get the FW pointer to derive ADSP header */ /* Get the FW pointer to derive ADSP header */
stripped_fw.data = fw->data; stripped_fw.data = fw->data;
...@@ -299,8 +300,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw, ...@@ -299,8 +300,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
for (i = 0; i < num_entry; i++, mod_entry++) { for (i = 0; i < num_entry; i++, mod_entry++) {
module = kzalloc(sizeof(*module), GFP_KERNEL); module = kzalloc(sizeof(*module), GFP_KERNEL);
if (!module) if (!module) {
return -ENOMEM; ret = -ENOMEM;
goto free_uuid_list;
}
uuid_bin = (uuid_le *)mod_entry->uuid.id; uuid_bin = (uuid_le *)mod_entry->uuid.id;
memcpy(&module->uuid, uuid_bin, sizeof(module->uuid)); memcpy(&module->uuid, uuid_bin, sizeof(module->uuid));
...@@ -311,8 +314,8 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw, ...@@ -311,8 +314,8 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
size = sizeof(int) * mod_entry->instance_max_count; size = sizeof(int) * mod_entry->instance_max_count;
module->instance_id = devm_kzalloc(ctx->dev, size, GFP_KERNEL); module->instance_id = devm_kzalloc(ctx->dev, size, GFP_KERNEL);
if (!module->instance_id) { if (!module->instance_id) {
kfree(module); ret = -ENOMEM;
return -ENOMEM; goto free_uuid_list;
} }
list_add_tail(&module->list, &skl->uuid_list); list_add_tail(&module->list, &skl->uuid_list);
...@@ -323,6 +326,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw, ...@@ -323,6 +326,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
} }
return 0; return 0;
free_uuid_list:
skl_freeup_uuid_list(skl);
return ret;
} }
void skl_freeup_uuid_list(struct skl_sst *ctx) void skl_freeup_uuid_list(struct skl_sst *ctx)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment