* [PATCH] ASoC: dapm: Fix a couple uninitialized ret variables
@ 2018-09-07 19:40 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-09-07 19:40 UTC (permalink / raw)
To: Liam Girdwood, Charles Keepax
Cc: alsa-devel, Mark Brown, kernel-janitors, Takashi Iwai
Smatch complains that these variables could be uninitialized. The first
one in snd_soc_dai_link_event() is probably a false positive, because
probably we know the lists are not empty. I would normally ignore the
warning, but GCC complains here as well so I just silenced the warning.
The "ret" in snd_soc_dapm_new_dai() does need to be initialized or it
leads to a bogus dereference in the caller.
Fixes: 3bbf5d34fd4a ("ASoC: dapm: Move error handling to snd_soc_dapm_new_control_unlocked")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 9f4edcd19e02..0dcdcc23dcfd 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3623,7 +3623,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
struct snd_pcm_hw_params *params = NULL;
struct snd_pcm_runtime *runtime = NULL;
unsigned int fmt;
- int ret;
+ int ret = 0;
config = rtd->dai_link->params + rtd->params_select;
@@ -3938,8 +3938,10 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd,
dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name);
w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template);
- if (IS_ERR(w))
+ if (IS_ERR(w)) {
+ ret = PTR_ERR(w);
goto outfree_kcontrol_news;
+ }
w->priv = rtd;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] ASoC: dapm: Fix a couple uninitialized ret variables
@ 2018-09-07 19:40 ` Dan Carpenter
0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2018-09-07 19:40 UTC (permalink / raw)
To: Liam Girdwood, Charles Keepax
Cc: alsa-devel, Mark Brown, kernel-janitors, Takashi Iwai
Smatch complains that these variables could be uninitialized. The first
one in snd_soc_dai_link_event() is probably a false positive, because
probably we know the lists are not empty. I would normally ignore the
warning, but GCC complains here as well so I just silenced the warning.
The "ret" in snd_soc_dapm_new_dai() does need to be initialized or it
leads to a bogus dereference in the caller.
Fixes: 3bbf5d34fd4a ("ASoC: dapm: Move error handling to snd_soc_dapm_new_control_unlocked")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
index 9f4edcd19e02..0dcdcc23dcfd 100644
--- a/sound/soc/soc-dapm.c
+++ b/sound/soc/soc-dapm.c
@@ -3623,7 +3623,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
struct snd_pcm_hw_params *params = NULL;
struct snd_pcm_runtime *runtime = NULL;
unsigned int fmt;
- int ret;
+ int ret = 0;
config = rtd->dai_link->params + rtd->params_select;
@@ -3938,8 +3938,10 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd,
dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name);
w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template);
- if (IS_ERR(w))
+ if (IS_ERR(w)) {
+ ret = PTR_ERR(w);
goto outfree_kcontrol_news;
+ }
w->priv = rtd;
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: dapm: Fix a couple uninitialized ret variables
2018-09-07 19:40 ` Dan Carpenter
@ 2018-09-10 14:22 ` Charles Keepax
-1 siblings, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2018-09-10 14:22 UTC (permalink / raw)
To: Dan Carpenter
Cc: alsa-devel, kernel-janitors, Takashi Iwai, Liam Girdwood, Mark Brown
On Fri, Sep 07, 2018 at 10:40:33PM +0300, Dan Carpenter wrote:
> Smatch complains that these variables could be uninitialized. The first
> one in snd_soc_dai_link_event() is probably a false positive, because
> probably we know the lists are not empty. I would normally ignore the
> warning, but GCC complains here as well so I just silenced the warning.
> The "ret" in snd_soc_dapm_new_dai() does need to be initialized or it
> leads to a bogus dereference in the caller.
>
> Fixes: 3bbf5d34fd4a ("ASoC: dapm: Move error handling to snd_soc_dapm_new_control_unlocked")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index 9f4edcd19e02..0dcdcc23dcfd 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -3623,7 +3623,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
> struct snd_pcm_hw_params *params = NULL;
> struct snd_pcm_runtime *runtime = NULL;
> unsigned int fmt;
> - int ret;
> + int ret = 0;
This one got fixed the other day in fc269c039644 ("ASoC: dapm:
Avoid uninitialised variable warning").
>
> config = rtd->dai_link->params + rtd->params_select;
>
> @@ -3938,8 +3938,10 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd,
> dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name);
>
> w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template);
> - if (IS_ERR(w))
> + if (IS_ERR(w)) {
> + ret = PTR_ERR(w);
> goto outfree_kcontrol_news;
> + }
Thanks for spotting this, looks good to me.
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
>
> w->priv = rtd;
>
Thanks,
Charles
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ASoC: dapm: Fix a couple uninitialized ret variables
@ 2018-09-10 14:22 ` Charles Keepax
0 siblings, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2018-09-10 14:22 UTC (permalink / raw)
To: Dan Carpenter
Cc: alsa-devel, kernel-janitors, Takashi Iwai, Liam Girdwood, Mark Brown
On Fri, Sep 07, 2018 at 10:40:33PM +0300, Dan Carpenter wrote:
> Smatch complains that these variables could be uninitialized. The first
> one in snd_soc_dai_link_event() is probably a false positive, because
> probably we know the lists are not empty. I would normally ignore the
> warning, but GCC complains here as well so I just silenced the warning.
> The "ret" in snd_soc_dapm_new_dai() does need to be initialized or it
> leads to a bogus dereference in the caller.
>
> Fixes: 3bbf5d34fd4a ("ASoC: dapm: Move error handling to snd_soc_dapm_new_control_unlocked")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c
> index 9f4edcd19e02..0dcdcc23dcfd 100644
> --- a/sound/soc/soc-dapm.c
> +++ b/sound/soc/soc-dapm.c
> @@ -3623,7 +3623,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w,
> struct snd_pcm_hw_params *params = NULL;
> struct snd_pcm_runtime *runtime = NULL;
> unsigned int fmt;
> - int ret;
> + int ret = 0;
This one got fixed the other day in fc269c039644 ("ASoC: dapm:
Avoid uninitialised variable warning").
>
> config = rtd->dai_link->params + rtd->params_select;
>
> @@ -3938,8 +3938,10 @@ snd_soc_dapm_new_dai(struct snd_soc_card *card, struct snd_soc_pcm_runtime *rtd,
> dev_dbg(card->dev, "ASoC: adding %s widget\n", link_name);
>
> w = snd_soc_dapm_new_control_unlocked(&card->dapm, &template);
> - if (IS_ERR(w))
> + if (IS_ERR(w)) {
> + ret = PTR_ERR(w);
> goto outfree_kcontrol_news;
> + }
Thanks for spotting this, looks good to me.
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
>
> w->priv = rtd;
>
Thanks,
Charles
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-09-10 14:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-07 19:40 [PATCH] ASoC: dapm: Fix a couple uninitialized ret variables Dan Carpenter
2018-09-07 19:40 ` Dan Carpenter
2018-09-10 14:22 ` Charles Keepax
2018-09-10 14:22 ` Charles Keepax
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.