ASoC: Intel: Skylake: fix memory leak of module on error exit path
authorColin Ian King <colin.king@canonical.com>
Thu, 29 Sep 2016 17:32:12 +0000 (18:32 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 29 Sep 2016 18:21:03 +0000 (11:21 -0700)
Currently there is a memory leak of module on a ENOMEM return path.
Fix this by kfree'ing module before returning.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/intel/skylake/skl-sst-utils.c

index 1aa0f37..3fe939c 100644 (file)
@@ -349,8 +349,10 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
                module->max_instance = mod_entry->instance_max_count;
                size = sizeof(int) * mod_entry->instance_max_count;
                module->instance_id = devm_kzalloc(ctx->dev, size, GFP_KERNEL);
-               if (!module->instance_id)
+               if (!module->instance_id) {
+                       kfree(module);
                        return -ENOMEM;
+               }
 
                list_add_tail(&module->list, &skl->uuid_list);