ASoC: Intel: Skylake: Fix mem leak in few functions
authorKamil Duljas <kamil.duljas@gmail.com>
Thu, 16 Nov 2023 12:51:50 +0000 (13:51 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 20 Jan 2024 10:51:39 +0000 (11:51 +0100)
[ Upstream commit d5c65be34df73fa01ed05611aafb73b440d89e29 ]

The resources should be freed when function return error.

Signed-off-by: Kamil Duljas <kamil.duljas@gmail.com>
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Link: https://lore.kernel.org/r/20231116125150.1436-1-kamil.duljas@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/intel/skylake/skl-pcm.c
sound/soc/intel/skylake/skl-sst-ipc.c

index ac3dc8c..29a03ee 100644 (file)
@@ -252,8 +252,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);
 
index 7a42527..fd9624a 100644 (file)
@@ -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;