[PATCH 2/4] ASoC: SOF: loader: fix memory leak in get_ext_windows

Ranjani Sridharan ranjani.sridharan at linux.intel.com
Wed Aug 26 01:58:52 CEST 2020


From: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>

sdev->info_window is allocated with kmemdup and never freed, use devm_
version since this is only used for first boot.

Fixes: 8d809c15acf23 ('ASoC: SOF: ext_manifest: parse windows')
Cc: Karol Trzcinski <karolx.trzcinski at linux.intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta at gmail.com>
Reviewed-by: Kai Vehmanen <kai.vehmanen at linux.intel.com>
Reviewed-by: Rander Wang <rander.wang at linux.intel.com>
Reviewed-by: Guennadi Liakhovetski <guennadi.liakhovetski at linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao at linux.intel.com>
Signed-off-by: Ranjani Sridharan <ranjani.sridharan at linux.intel.com>
---
 sound/soc/sof/loader.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sof/loader.c b/sound/soc/sof/loader.c
index 25dc28ebafb7..42e0e3e58869 100644
--- a/sound/soc/sof/loader.c
+++ b/sound/soc/sof/loader.c
@@ -33,7 +33,8 @@ static int get_ext_windows(struct snd_sof_dev *sdev,
 	}
 
 	/* keep a local copy of the data */
-	sdev->info_window = kmemdup(w, ext_hdr->hdr.size, GFP_KERNEL);
+	sdev->info_window = devm_kmemdup(sdev->dev, w, ext_hdr->hdr.size,
+					 GFP_KERNEL);
 	if (!sdev->info_window)
 		return -ENOMEM;
 
-- 
2.25.1



More information about the Alsa-devel mailing list