ASoC: SOF: amd: Fix memory leak in amd_sof_acp_probe()
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>
This commit is contained in:
parent
a4832a9468
commit
222be59e5e
@ -561,17 +561,27 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev)
|
||||
adata->signed_fw_image = false;
|
||||
dmi_id = dmi_first_match(acp_sof_quirk_table);
|
||||
if (dmi_id && dmi_id->driver_data) {
|
||||
adata->fw_code_bin = kasprintf(GFP_KERNEL, "%s/sof-%s-code.bin",
|
||||
plat_data->fw_filename_prefix,
|
||||
chip->name);
|
||||
adata->fw_data_bin = kasprintf(GFP_KERNEL, "%s/sof-%s-data.bin",
|
||||
plat_data->fw_filename_prefix,
|
||||
chip->name);
|
||||
adata->signed_fw_image = dmi_id->driver_data;
|
||||
adata->fw_code_bin = devm_kasprintf(sdev->dev, GFP_KERNEL,
|
||||
"%s/sof-%s-code.bin",
|
||||
plat_data->fw_filename_prefix,
|
||||
chip->name);
|
||||
if (!adata->fw_code_bin) {
|
||||
ret = -ENOMEM;
|
||||
goto free_ipc_irq;
|
||||
}
|
||||
|
||||
dev_dbg(sdev->dev, "fw_code_bin:%s, fw_data_bin:%s\n", adata->fw_code_bin,
|
||||
adata->fw_data_bin);
|
||||
adata->fw_data_bin = devm_kasprintf(sdev->dev, GFP_KERNEL,
|
||||
"%s/sof-%s-data.bin",
|
||||
plat_data->fw_filename_prefix,
|
||||
chip->name);
|
||||
if (!adata->fw_data_bin) {
|
||||
ret = -ENOMEM;
|
||||
goto free_ipc_irq;
|
||||
}
|
||||
|
||||
adata->signed_fw_image = dmi_id->driver_data;
|
||||
}
|
||||
|
||||
adata->enable_fw_debug = enable_fw_debug;
|
||||
acp_memory_init(sdev);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user