ASoC: qcom: audioreach: add support for static calibration
Subsystems (3)
Hello Srinivas Kandagatla,
Commit c7ed4c2debfd ("ASoC: qcom: audioreach: add support for static calibration") from Aug 19, 2025 (linux-next), leads to the following Smatch static checker warning:
sound/soc/qcom/qdsp6/topology.c:613 audioreach_widget_load_module_common()
error: potential NULL/IS_ERR bug 'mod'
sound/soc/qcom/qdsp6/topology.c
591 static int audioreach_widget_load_module_common(struct snd_soc_component *component,
592 int index, struct snd_soc_dapm_widget *w,
593 struct snd_soc_tplg_dapm_widget *tplg_w)
594 {
595 struct q6apm *apm = dev_get_drvdata(component->dev);
596 struct audioreach_container *cont;
597 struct audioreach_sub_graph *sg;
598 struct audioreach_module *mod;
599 struct snd_soc_dobj *dobj;
600
601 sg = audioreach_parse_sg_tokens(apm, &tplg_w->priv);
602 if (IS_ERR(sg))
603 return PTR_ERR(sg);
604
605 cont = audioreach_parse_cont_tokens(apm, sg, &tplg_w->priv);
606 if (IS_ERR(cont))
607 return PTR_ERR(cont);
608
609 mod = audioreach_parse_common_tokens(apm, cont, &tplg_w->priv, w);
610 if (IS_ERR(mod))
611 return PTR_ERR(mod);The audioreach_parse_common_tokens() can return either error pointers or NULL.
612
--> 613 mod->data = audioreach_get_module_priv_data(&tplg_w->priv);
^^^^^^^^^Only checked for error pointers, and it could still be NULL
614
615 dobj = &w->dobj;
616 dobj->private = mod;
617
618 return 0;
619 }regards,
dan carpenter
Quoted 9 lines · Dan Carpenter
Hello Srinivas Kandagatla,
Commit
c7ed4c2debfd("ASoC: qcom: audioreach: add support for static calibration") from Aug 19, 2025 (linux-next), leads to the following Smatch static checker warning:
sound/soc/qcom/qdsp6/topology.c:613audioreach_widget_load_module_common()
error: potential NULL/IS_ERR bug 'mod'
Thansk Dan for reporting this,
Quoted 23 lines
sound/soc/qcom/qdsp6/topology.c591 static int audioreach_widget_load_module_common(struct snd_soc_component *component, 592 int index, struct snd_soc_dapm_widget *w, 593 struct snd_soc_tplg_dapm_widget *tplg_w) 594 { 595 struct q6apm *apm = dev_get_drvdata(component->dev); 596 struct audioreach_container *cont; 597 struct audioreach_sub_graph *sg; 598 struct audioreach_module *mod; 599 struct snd_soc_dobj *dobj; 600 601 sg = audioreach_parse_sg_tokens(apm, &tplg_w->priv); 602 if (IS_ERR(sg)) 603 return PTR_ERR(sg); 604 605 cont = audioreach_parse_cont_tokens(apm, sg, &tplg_w->priv); 606 if (IS_ERR(cont)) 607 return PTR_ERR(cont); 608 609 mod = audioreach_parse_common_tokens(apm, cont, &tplg_w->priv, w); 610 if (IS_ERR(mod)) 611 return PTR_ERR(mod);
Quoted 3 lines
The
audioreach_parse_common_tokens()can return either error pointers or NULL.
Yes, its possible that we could get NULL if we have a corrupted or malformed topology graph.
Quoted 4 lines
612 --> 613 mod->data = audioreach_get_module_priv_data(&tplg_w->priv); ^^^^^^^^^Only checked for error pointers, and it could still be NULL
below change should address the concern.
(quoted diff) +0 -0
b/sound/soc/qcom/qdsp6/topology.c
index ec51fabd98cb..62fdcf433cde 100644
sound/soc/qcom/qdsp6/topology.c +0 -0
@@ -607,8 +607,8 @@ static int
audioreach_widget_load_module_common(struct snd_soc_component *compon
return PTR_ERR(cont);
mod = audioreach_parse_common_tokens(apm, cont, &tplg_w->priv, w);- if (IS_ERR(mod))
- return PTR_ERR(mod);
+ if (IS_ERR_OR_NULL(mod))
+ return mod ? PTR_ERR(mod): -ENODEV;
mod->data = audioreach_get_module_priv_data(&tplg_w->priv);
Will send out a patch for this.
--srini
Quoted 10 lines
614 615 dobj = &w->dobj; 616 dobj->private = mod; 617 618 return 0; 619 }regards,
dan carpenter