Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1539307 > unrolled thread

[PATCH] ASoC: topology: avoid uninitialized kcontrol_type

Started byArnd Bergmann <arnd@arndb.de>
First post2016-12-09 13:00 +0100
Last post2016-12-10 16:50 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] ASoC: topology: avoid uninitialized kcontrol_type Arnd Bergmann <arnd@arndb.de> - 2016-12-09 13:00 +0100
    Re: [PATCH] ASoC: topology: avoid uninitialized kcontrol_type Takashi Sakamoto <o-takashi@sakamocchi.jp> - 2016-12-10 16:50 +0100

#1539307 — [PATCH] ASoC: topology: avoid uninitialized kcontrol_type

FromArnd Bergmann <arnd@arndb.de>
Date2016-12-09 13:00 +0100
Subject[PATCH] ASoC: topology: avoid uninitialized kcontrol_type
Message-ID<sMs0h-2MT-15@gated-at.bofh.it>
When num_kcontrols is zero, widget->dobj.widget.kcontrol_type
gets set to an uninitialized local variable:

sound/soc/soc-topology.c: In function 'soc_tplg_dapm_widget_create':
sound/soc/soc-topology.c:1566:36: error: 'kcontrol_type' may be used uninitialized in this function [-Werror=maybe-uninitialized]

I could not figure out which of the valid types would be appropriate
here, so this sets it to '0', which is invalid but at least well-defined
here. There is probably a better way to address the issue.

Fixes: eea3dd4f1247 ("ASoC: topology: Only free TLV for volume mixers of a widget")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 sound/soc/soc-topology.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
index 11feb19e9730..65670b2b408c 100644
--- a/sound/soc/soc-topology.c
+++ b/sound/soc/soc-topology.c
@@ -1485,6 +1485,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
 	tplg->pos +=
 		(sizeof(struct snd_soc_tplg_dapm_widget) + w->priv.size);
 	if (w->num_kcontrols == 0) {
+		kcontrol_type = 0;
 		template.num_kcontrols = 0;
 		goto widget;
 	}
-- 
2.9.0

[toc] | [next] | [standalone]


#1539853

FromTakashi Sakamoto <o-takashi@sakamocchi.jp>
Date2016-12-10 16:50 +0100
Message-ID<sMS4p-44l-1@gated-at.bofh.it>
In reply to#1539307
Hi Arnd,

On Dec 9 2016 20:51, Arnd Bergmann wrote:
> When num_kcontrols is zero, widget->dobj.widget.kcontrol_type
> gets set to an uninitialized local variable:
>
> sound/soc/soc-topology.c: In function 'soc_tplg_dapm_widget_create':
> sound/soc/soc-topology.c:1566:36: error: 'kcontrol_type' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> I could not figure out which of the valid types would be appropriate
> here, so this sets it to '0', which is invalid but at least well-defined
> here. There is probably a better way to address the issue.
>
> Fixes: eea3dd4f1247 ("ASoC: topology: Only free TLV for volume mixers of a widget")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  sound/soc/soc-topology.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
> index 11feb19e9730..65670b2b408c 100644
> --- a/sound/soc/soc-topology.c
> +++ b/sound/soc/soc-topology.c
> @@ -1485,6 +1485,7 @@ static int soc_tplg_dapm_widget_create(struct soc_tplg *tplg,
>  	tplg->pos +=
>  		(sizeof(struct snd_soc_tplg_dapm_widget) + w->priv.size);
>  	if (w->num_kcontrols == 0) {
> +		kcontrol_type = 0;
>  		template.num_kcontrols = 0;
>  		goto widget;
>  	}

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

This bug was already reported but not fixed yet:
[alsa-devel] [bug report] ASoC: topology: Only free TLV for volume 
mixers of a widget
http://mailman.alsa-project.org/pipermail/alsa-devel/2016-December/115577.html

As you said, this solution looks band-aid, however we have no 
alternatives to fix the warning...


Regards

Takashi Sakamoto

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web