Re: [PATCH v1] ASoC: Intel: avs: Add NULL check in avs_component_probe()

From: Cezary Rojewski
Date: Wed Apr 02 2025 - 10:04:07 EST


On 2025-04-01 4:32 PM, Henry Martin wrote:
devm_kasprintf() returns NULL when memory allocation fails. Currently,
avs_component_probe() does not check for this case, which results in a
NULL pointer dereference.

Add NULL check after devm_kasprintf() to prevent this issue.

This basically repeats the title, I'd suggest to drop this very line. In regard to the title, I believe:

ASoC: Intel: avs: Fix null-ptr-deref in avs_component_probe()

is more straightforward. That's what you're doing here afterall, fixing stuff.


Fixes: 739c031110da ("ASoC: Intel: avs: Provide support for fallback topology")
Signed-off-by: Henry Martin <bsdhenrymartin@xxxxxxxxx>
Good catch, thanks for sending the fix, Martin. I'm rather strict when it comes to wording title/message but nothing more than a nitpick in this case.

Whether you would be willing to provide v2 or not, feel free to add my tag:

Reviewed-by: Cezary Rojewski <cezary.rojewski@xxxxxxxxx>

---
sound/soc/intel/avs/pcm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index dac463390da1..7072bcf4e56f 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -927,7 +927,8 @@ static int avs_component_probe(struct snd_soc_component *component)
else
mach->tplg_filename = devm_kasprintf(adev->dev, GFP_KERNEL,
"hda-generic-tplg.bin");
-
+ if (!mach->tplg_filename)
+ return -ENOMEM;
filename = kasprintf(GFP_KERNEL, "%s/%s", component->driver->topology_name_prefix,
mach->tplg_filename);
if (!filename)