[PATCH] ASoC: SOF: topology: check if machine is NULL during tplg load

Laurentiu Mihalcea posted 1 patch 7 months, 3 weeks ago
sound/soc/sof/topology.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] ASoC: SOF: topology: check if machine is NULL during tplg load
Posted by Laurentiu Mihalcea 7 months, 3 weeks ago
From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>

Check if "sof_pdata->machine" is NULL before calling the machine-specific
"get_function_tplg_files()". Otherwise, for OF-based machines (which set
the "of_machine" instead of the "machine" field), the operation will
result in a NULL pointer dereference fault.

Fixes: 6d5997c412cc ("ASoC: SOF: topology: load multiple topologies")
Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
---
 sound/soc/sof/topology.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/sof/topology.c b/sound/soc/sof/topology.c
index e19ba94f2c80..5d3ee3a86392 100644
--- a/sound/soc/sof/topology.c
+++ b/sound/soc/sof/topology.c
@@ -2481,7 +2481,7 @@ int snd_sof_load_topology(struct snd_soc_component *scomp, const char *file)
 	if (!tplg_files)
 		return -ENOMEM;
 
-	if (sof_pdata->machine->get_function_tplg_files) {
+	if (sof_pdata->machine && sof_pdata->machine->get_function_tplg_files) {
 		tplg_cnt = sof_pdata->machine->get_function_tplg_files(scomp->card,
 								       sof_pdata->machine,
 								       tplg_filename_prefix,
-- 
2.34.1
Re: [PATCH] ASoC: SOF: topology: check if machine is NULL during tplg load
Posted by Daniel Baluta 7 months, 3 weeks ago
On Mon, Apr 28, 2025 at 7:16 PM Laurentiu Mihalcea
<laurentiumihalcea111@gmail.com> wrote:
>
> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>
> Check if "sof_pdata->machine" is NULL before calling the machine-specific
> "get_function_tplg_files()". Otherwise, for OF-based machines (which set
> the "of_machine" instead of the "machine" field), the operation will
> result in a NULL pointer dereference fault.
>
> Fixes: 6d5997c412cc ("ASoC: SOF: topology: load multiple topologies")
> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>

Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>

I think same patch was sent by Julien, but this one has better explanation.

Julien, I think you can add your S-o-B tag here.

Thanks,
Daniel.
Re: [PATCH] ASoC: SOF: topology: check if machine is NULL during tplg load
Posted by Laurentiu Mihalcea 7 months, 3 weeks ago

On 4/28/2025 7:50 PM, Daniel Baluta wrote:
> On Mon, Apr 28, 2025 at 7:16 PM Laurentiu Mihalcea
> <laurentiumihalcea111@gmail.com> wrote:
>> From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
>>
>> Check if "sof_pdata->machine" is NULL before calling the machine-specific
>> "get_function_tplg_files()". Otherwise, for OF-based machines (which set
>> the "of_machine" instead of the "machine" field), the operation will
>> result in a NULL pointer dereference fault.
>>
>> Fixes: 6d5997c412cc ("ASoC: SOF: topology: load multiple topologies")
>> Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>
> Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
>
> I think same patch was sent by Julien, but this one has better explanation.
>
> Julien, I think you can add your S-o-B tag here.
>
> Thanks,
> Daniel.

sorry for the noise, somehow I missed Julien's patch. Dropping this in favor of
his.