All of lore.kernel.org
 help / color / mirror / Atom feed
* [bug report] ASoC: qcom: audioreach: add support for static calibration
@ 2025-08-22  8:07 Dan Carpenter
  2025-08-22  8:40 ` Srinivas Kandagatla
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-08-22  8:07 UTC (permalink / raw)
  To: Srinivas Kandagatla; +Cc: linux-sound

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] ASoC: qcom: audioreach: add support for static calibration
  2025-08-22  8:07 [bug report] ASoC: qcom: audioreach: add support for static calibration Dan Carpenter
@ 2025-08-22  8:40 ` Srinivas Kandagatla
  0 siblings, 0 replies; 2+ messages in thread
From: Srinivas Kandagatla @ 2025-08-22  8:40 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-sound


On 8/22/25 9:07 AM, Dan Carpenter wrote:
> 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'
> 

Thansk Dan for reporting this,
> 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.
> 
Yes, its possible that we could get NULL if we have a corrupted or
malformed topology graph.


>     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.

diff --git a/sound/soc/qcom/qdsp6/topology.c
b/sound/soc/qcom/qdsp6/topology.c
index ec51fabd98cb..62fdcf433cde 100644
--- a/sound/soc/qcom/qdsp6/topology.c
+++ b/sound/soc/qcom/qdsp6/topology.c
@@ -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
> 
>     614 
>     615         dobj = &w->dobj;
>     616         dobj->private = mod;
>     617 
>     618         return 0;
>     619 }
> 
> regards,
> dan carpenter


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-08-22  8:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22  8:07 [bug report] ASoC: qcom: audioreach: add support for static calibration Dan Carpenter
2025-08-22  8:40 ` Srinivas Kandagatla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.