]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
ASoC: SOF: amd: Fix memory leak in amd_sof_acp_probe()
authorCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Tue, 19 Dec 2023 03:07:23 +0000 (05:07 +0200)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:43 +0000 (18:19 -0400)
commit88028c45d5871dfc449b2b0a27abf6428453a5ec
tree230c06a6b2d93f0e5d9c1ea650c02bd9563be2d1
parent9439808c87e6db8b8d56325b728c739b38c8c71e
ASoC: SOF: amd: Fix memory leak in amd_sof_acp_probe()

[ Upstream commit 222be59e5eed1554119294edc743ee548c2371d0 ]

Driver uses kasprintf() to initialize fw_{code,data}_bin members of
struct acp_dev_data, but kfree() is never called to deallocate the
memory, which results in a memory leak.

Fix the issue by switching to devm_kasprintf(). Additionally, ensure the
allocation was successful by checking the pointer validity.

Fixes: f7da88003c53 ("ASoC: SOF: amd: Enable signed firmware image loading for Vangogh platform")
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Link: https://msgid.link/r/20231219030728.2431640-6-cristian.ciocaltea@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/soc/sof/amd/acp.c