Skip to contentSkip to conversation

ASoC: dapm: Implement and instantiate DAI widgets

bug report Dan Carpenter 5 participants 7 messages Jan 19, 2017 – Jan 20, 2017

lore
Share & tools
lore
#0 lore raw

Hello Mark Brown,

The patch 888df395ebc5: "ASoC: dapm: Implement and instantiate DAI widgets" from Feb 16, 2012, leads to the following static checker warning:

	sound/soc/soc-dapm.c:3944 snd_soc_dapm_new_dai_widgets()
	error: 'w' dereferencing possible ERR_PTR()

sound/soc/soc-dapm.c
3929 if (dai->driver->playback.stream_name) {

  3930                  template.id = snd_soc_dapm_dai_in;
  3931                  template.name = dai->driver->playback.stream_name;
  3932                  template.sname = dai->driver->playback.stream_name;

3933
3934 dev_dbg(dai->dev, "ASoC: adding %s widget\n",
3935 template.name);
3936
3937 w = snd_soc_dapm_new_control_unlocked(dapm, &template);

This can either return NULL or ERR_PTR(-EPROBE_DEFER).

  3938                  if (!w) {
  3939                          dev_err(dapm->dev, "ASoC: Failed to create %s widget\n",
  3940                                  dai->driver->playback.stream_name);
  3941                          return -ENOMEM;
  3942                  }
  3943  
  3944                  w->priv = dai;
                        ^^^^^^^^^^^^^

  3945                  dai->playback_widget = w;
  3946          }

regards,
dan carpenter

#1 lore raw

There is another warning some lines later as well:

sound/soc/soc-dapm.c:3963 snd_soc_dapm_new_dai_widgets()
error: 'w' dereferencing possible ERR_PTR()

regards,
dan carpenter

#2 lore raw
In reply to Dan Carpenter
Quoted 1 line · Dan Carpenter

Hello Mark Brown,

Dan you need to update Mark's email in your address book, its been a while since he moved away from wolfson..

Quoted 39 lines

The patch 888df395ebc5: "ASoC: dapm: Implement and instantiate DAI widgets" from Feb 16, 2012, leads to the following static checker warning:

	sound/soc/soc-dapm.c:3944 snd_soc_dapm_new_dai_widgets()
	error: 'w' dereferencing possible ERR_PTR()

sound/soc/soc-dapm.c
3929 if (dai->driver->playback.stream_name) {

  3930                  template.id = snd_soc_dapm_dai_in;
  3931                  template.name = dai->driver->playback.stream_name;
  3932                  template.sname = dai->driver->playback.stream_name;

3933
3934 dev_dbg(dai->dev, "ASoC: adding %s widget\n",
3935 template.name);
3936
3937 w = snd_soc_dapm_new_control_unlocked(dapm, &template);

This can either return NULL or ERR_PTR(-EPROBE_DEFER).

  3938                  if (!w) {
  3939                          dev_err(dapm->dev, "ASoC: Failed to create %s widget\n",
  3940                                  dai->driver->playback.stream_name);
  3941                          return -ENOMEM;
  3942                  }
  3943  
  3944                  w->priv = dai;
                        ^^^^^^^^^^^^^

  3945                  dai->playback_widget = w;
  3946          }

regards,
dan carpenter
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

Signature · 1 line
~Vinod
#3 lore raw
Quoted 6 lines · Vinod Koul
Quoted 1 line · Dan Carpenter

Hello Mark Brown,

Dan you need to update Mark's email in your address book, its been a while since he moved away from wolfson..

Oh crap! This warning is from 2012... I really need to update my scripts so I stop sending really ancient warnings.

regards,
dan carpenter

#4 lore raw
Quoted 10 lines · Dan Carpenter
Quoted 6 lines · Vinod Koul
Quoted 1 line · Dan Carpenter

Hello Mark Brown,

Dan you need to update Mark's email in your address book, its been a while since he moved away from wolfson..

Oh crap! This warning is from 2012... I really need to update my scripts so I stop sending really ancient warnings.

The warning is correct. It's just the wrong commit. The issue was introduced with commit 37e1df8c95e2 ("ASoC: dapm: handle probe deferrals"). The commit introduces ERR_PTR() as a possible return value for the function, but does not update all callers.

- Lars

#5 lore raw
Quoted 9 lines · Lars-Peter Clausen
Quoted 8 lines · Dan Carpenter
Quoted 6 lines · Vinod Koul
Quoted 1 line · Dan Carpenter

Hello Mark Brown,

Dan you need to update Mark's email in your address book, its been a while since he moved away from wolfson..

Quoted 7 lines
Quoted 2 lines

Oh crap! This warning is from 2012... I really need to update my scripts so I stop sending really ancient warnings.

The warning is correct. It's just the wrong commit. The issue was introduced with commit 37e1df8c95e2 ("ASoC: dapm: handle probe deferrals"). The commit introduces ERR_PTR() as a possible return value for the function, but does not update all callers.

Yeah so the DAPM code was violating the regulator and clock
APIs by ignoring potential error pointers (just doing NULL checks), so I made it aware of this, but oops it created a downstream problem that everyone using DAPM gets the cascaded error pointer.

I just have to bit the bullet and make a patch updating all DAPM consumers, it's just work, I'll keep you in CC.

Yours,
Linus Walleij

#6 lore raw
Quoted 7 lines · Linus Walleij
Quoted 4 lines · Lars-Peter Clausen

The warning is correct. It's just the wrong commit. The issue was introduced with commit 37e1df8c95e2 ("ASoC: dapm: handle probe deferrals"). The commit introduces ERR_PTR() as a possible return value for the function, but does not update all callers.

Quoted 7 lines

Yeah so the DAPM code was violating the regulator and clock
APIs by ignoring potential error pointers (just doing NULL checks), so I made it aware of this, but oops it created a downstream problem that everyone using DAPM gets the cascaded error pointer.

I just have to bit the bullet and make a patch updating all DAPM consumers, it's just work, I'll keep you in CC.

Yeah, the error handling was already broken - all your patch did was make it easier for a static checker to spot that there were problems.