ASoC: SOF: acp: Add prevent against NULL
Subsystems (3)
PATCH 1/1 ASoC: SOF: acp: Add prevent against NULL
When kasprintf function fail, then NULL is returned. The callers dereference them without null checked.
Signed-off-by Kamil Duljas <[email protected]>
--- sound/soc/sof/amd/acp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
sound/soc/sof/amd/acp.c +8 -4
@@ -548,11 +548,15 @@ int amd_sof_acp_probe(struct snd_sof_dev *sdev) 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); + plat_data->fw_filename_prefix, + chip->name); +if (!adata->fw_code_bin) +return -ENOMEM ; adata->fw_data_bin =kasprintf (GFP_KERNEL ,"%s/sof-%s-data.bin" , - plat_data->fw_filename_prefix, - chip->name); + plat_data->fw_filename_prefix, + chip->name); +if (!adata->fw_data_bin) +return -ENOMEM ; adata->signed_fw_image = dmi_id->driver_data; dev_dbg(sdev->dev, "fw_code_bin:%s, fw_data_bin:%s\n", adata->fw_code_bin,
Signature · 1 line
2.42.0.windows.2
Mark Brown
maintainersound/soc/sof/amd/acp.c int amd_sof_acp_probe(struct snd_sof_dev *sdev) · line 552
Quoted 5 lines · Kamil Duljas
sound/soc/sof/amd/acp.c +2
-2adata->fw_code_bin =kasprintf (GFP_KERNEL ,"%s/sof-%s-code.bin" , - plat_data->fw_filename_prefix, - chip->name); + plat_data->fw_filename_prefix, + chip->name);
Plese don't include spurious indentation changes like this, it just makes the diff much harder to read.
sound/soc/sof/amd/acp.c int amd_sof_acp_probe(struct snd_sof_dev *sdev) · line 559
Quoted 9 lines
sound/soc/sof/amd/acp.c +6
-2+if (!adata->fw_code_bin) +return -ENOMEM ; adata->fw_data_bin =kasprintf (GFP_KERNEL ,"%s/sof-%s-data.bin" , - plat_data->fw_filename_prefix, - chip->name); + plat_data->fw_filename_prefix, + chip->name); +if (!adata->fw_data_bin) +return -ENOMEM ;
This now leaks the code binary...