[PATCH] ASoC: SOF: acp: Add prevent against NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When kasprintf function fail, then NULL is returned. The callers
dereference them without null checked.

Signed-off-by: Kamil Duljas <kamil.duljas@xxxxxxxxx>
---
 sound/soc/sof/amd/acp.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sof/amd/acp.c b/sound/soc/sof/amd/acp.c
index 603ea5fc0d0d..c60a3e28b5f3 100644
--- a/sound/soc/sof/amd/acp.c
+++ b/sound/soc/sof/amd/acp.c
@@ -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,
-- 
2.42.0.windows.2




[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux