[alsa-devel] [asoc:for-5.1 255/257] sound/soc/samsung/odroid.c:298:22: warning: 'cpu_dai' may be used uninitialized in this function

kbuild test robot lkp at intel.com
Wed Feb 20 19:51:07 CET 2019


tree:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-5.1
head:   70b773219a32c7b8f3e53e041bc023ad99fd81f4
commit: d832d2b246c516eacb2d0ba53ec17ed59c3cd62b [255/257] ASoC: samsung: odroid: Fix of_node refcount unbalance
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gnu-gcc (Debian 8.2.0-11) 8.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout d832d2b246c516eacb2d0ba53ec17ed59c3cd62b
        # save the attached .config to linux build tree
        GCC_VERSION=8.2.0 make.cross ARCH=sh 

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

   sound/soc/samsung/odroid.c: In function 'odroid_audio_probe':
>> sound/soc/samsung/odroid.c:298:22: warning: 'cpu_dai' may be used uninitialized in this function [-Wmaybe-uninitialized]
     priv->clk_i2s_bus = of_clk_get_by_name(cpu_dai, "iis");
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/cpu_dai +298 sound/soc/samsung/odroid.c

aba611fc Sylwester Nawrocki 2017-04-21  193  
aba611fc Sylwester Nawrocki 2017-04-21  194  static int odroid_audio_probe(struct platform_device *pdev)
aba611fc Sylwester Nawrocki 2017-04-21  195  {
aba611fc Sylwester Nawrocki 2017-04-21  196  	struct device *dev = &pdev->dev;
bc3cf17b Sylwester Nawrocki 2019-02-14  197  	struct device_node *cpu, *cpu_dai, *codec;
aba611fc Sylwester Nawrocki 2017-04-21  198  	struct odroid_priv *priv;
aba611fc Sylwester Nawrocki 2017-04-21  199  	struct snd_soc_card *card;
bc3cf17b Sylwester Nawrocki 2019-02-14  200  	struct snd_soc_dai_link *link, *codec_link;
bc3cf17b Sylwester Nawrocki 2019-02-14  201  	int num_pcms, ret, i;
bc3cf17b Sylwester Nawrocki 2019-02-14  202  	struct of_phandle_args args = {};
aba611fc Sylwester Nawrocki 2017-04-21  203  
aba611fc Sylwester Nawrocki 2017-04-21  204  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
aba611fc Sylwester Nawrocki 2017-04-21  205  	if (!priv)
aba611fc Sylwester Nawrocki 2017-04-21  206  		return -ENOMEM;
aba611fc Sylwester Nawrocki 2017-04-21  207  
aba611fc Sylwester Nawrocki 2017-04-21  208  	card = &priv->card;
aba611fc Sylwester Nawrocki 2017-04-21  209  	card->dev = dev;
aba611fc Sylwester Nawrocki 2017-04-21  210  
aba611fc Sylwester Nawrocki 2017-04-21  211  	card->owner = THIS_MODULE;
aba611fc Sylwester Nawrocki 2017-04-21  212  	card->fully_routed = true;
aba611fc Sylwester Nawrocki 2017-04-21  213  
b5c16a24 Sylwester Nawrocki 2019-02-14  214  	spin_lock_init(&priv->lock);
aba611fc Sylwester Nawrocki 2017-04-21  215  	snd_soc_card_set_drvdata(card, priv);
aba611fc Sylwester Nawrocki 2017-04-21  216  
aba611fc Sylwester Nawrocki 2017-04-21  217  	ret = snd_soc_of_parse_card_name(card, "model");
aba611fc Sylwester Nawrocki 2017-04-21  218  	if (ret < 0)
aba611fc Sylwester Nawrocki 2017-04-21  219  		return ret;
aba611fc Sylwester Nawrocki 2017-04-21  220  
aba611fc Sylwester Nawrocki 2017-04-21  221  	if (of_property_read_bool(dev->of_node, "samsung,audio-widgets")) {
aba611fc Sylwester Nawrocki 2017-04-21  222  		ret = snd_soc_of_parse_audio_simple_widgets(card,
aba611fc Sylwester Nawrocki 2017-04-21  223  						"samsung,audio-widgets");
aba611fc Sylwester Nawrocki 2017-04-21  224  		if (ret < 0)
aba611fc Sylwester Nawrocki 2017-04-21  225  			return ret;
aba611fc Sylwester Nawrocki 2017-04-21  226  	}
aba611fc Sylwester Nawrocki 2017-04-21  227  
aba611fc Sylwester Nawrocki 2017-04-21  228  	if (of_property_read_bool(dev->of_node, "samsung,audio-routing")) {
aba611fc Sylwester Nawrocki 2017-04-21  229  		ret = snd_soc_of_parse_audio_routing(card,
aba611fc Sylwester Nawrocki 2017-04-21  230  						"samsung,audio-routing");
aba611fc Sylwester Nawrocki 2017-04-21  231  		if (ret < 0)
aba611fc Sylwester Nawrocki 2017-04-21  232  			return ret;
aba611fc Sylwester Nawrocki 2017-04-21  233  	}
aba611fc Sylwester Nawrocki 2017-04-21  234  
bc3cf17b Sylwester Nawrocki 2019-02-14  235  	card->dai_link = odroid_card_dais;
bc3cf17b Sylwester Nawrocki 2019-02-14  236  	card->num_links = ARRAY_SIZE(odroid_card_dais);
aba611fc Sylwester Nawrocki 2017-04-21  237  
aba611fc Sylwester Nawrocki 2017-04-21  238  	cpu = of_get_child_by_name(dev->of_node, "cpu");
aba611fc Sylwester Nawrocki 2017-04-21  239  	codec = of_get_child_by_name(dev->of_node, "codec");
bc3cf17b Sylwester Nawrocki 2019-02-14  240  	link = card->dai_link;
bc3cf17b Sylwester Nawrocki 2019-02-14  241  	codec_link = &card->dai_link[1];
bc3cf17b Sylwester Nawrocki 2019-02-14  242  
bc3cf17b Sylwester Nawrocki 2019-02-14  243  	/*
bc3cf17b Sylwester Nawrocki 2019-02-14  244  	 * For backwards compatibility create the secondary CPU DAI link only
bc3cf17b Sylwester Nawrocki 2019-02-14  245  	 * if there are 2 CPU DAI entries in the cpu sound-dai property in DT.
f89aea0f Sylwester Nawrocki 2019-02-15  246  	 * Also add required DAPM routes not available in old DTS.
bc3cf17b Sylwester Nawrocki 2019-02-14  247  	 */
bc3cf17b Sylwester Nawrocki 2019-02-14  248  	num_pcms = of_count_phandle_with_args(cpu, "sound-dai",
bc3cf17b Sylwester Nawrocki 2019-02-14  249  					      "#sound-dai-cells");
f89aea0f Sylwester Nawrocki 2019-02-15  250  	if (num_pcms == 1) {
f89aea0f Sylwester Nawrocki 2019-02-15  251  		card->dapm_routes = odroid_dapm_routes;
f89aea0f Sylwester Nawrocki 2019-02-15  252  		card->num_dapm_routes = ARRAY_SIZE(odroid_dapm_routes);
bc3cf17b Sylwester Nawrocki 2019-02-14  253  		card->num_links--;
f89aea0f Sylwester Nawrocki 2019-02-15  254  	}
bc3cf17b Sylwester Nawrocki 2019-02-14  255  
bc3cf17b Sylwester Nawrocki 2019-02-14  256  	for (i = 0; i < num_pcms; i++, link += 2) {
bc3cf17b Sylwester Nawrocki 2019-02-14  257  		ret = of_parse_phandle_with_args(cpu, "sound-dai",
bc3cf17b Sylwester Nawrocki 2019-02-14  258  						 "#sound-dai-cells", i, &args);
bc3cf17b Sylwester Nawrocki 2019-02-14  259  		if (ret < 0)
d832d2b2 Sylwester Nawrocki 2019-02-20  260  			break;
aba611fc Sylwester Nawrocki 2017-04-21  261  
bc3cf17b Sylwester Nawrocki 2019-02-14  262  		if (!args.np) {
bc3cf17b Sylwester Nawrocki 2019-02-14  263  			dev_err(dev, "sound-dai property parse error: %d\n", ret);
d832d2b2 Sylwester Nawrocki 2019-02-20  264  			ret = -EINVAL;
d832d2b2 Sylwester Nawrocki 2019-02-20  265  			break;
aba611fc Sylwester Nawrocki 2017-04-21  266  		}
aba611fc Sylwester Nawrocki 2017-04-21  267  
bc3cf17b Sylwester Nawrocki 2019-02-14  268  		ret = snd_soc_get_dai_name(&args, &link->cpu_dai_name);
bc3cf17b Sylwester Nawrocki 2019-02-14  269  		of_node_put(args.np);
bc3cf17b Sylwester Nawrocki 2019-02-14  270  
aba611fc Sylwester Nawrocki 2017-04-21  271  		if (ret < 0)
d832d2b2 Sylwester Nawrocki 2019-02-20  272  			break;
bc3cf17b Sylwester Nawrocki 2019-02-14  273  	}
d832d2b2 Sylwester Nawrocki 2019-02-20  274  	if (ret == 0)
bc3cf17b Sylwester Nawrocki 2019-02-14  275  		cpu_dai = of_parse_phandle(cpu, "sound-dai", 0);
d832d2b2 Sylwester Nawrocki 2019-02-20  276  
bc3cf17b Sylwester Nawrocki 2019-02-14  277  	of_node_put(cpu);
bc3cf17b Sylwester Nawrocki 2019-02-14  278  	of_node_put(codec);
d832d2b2 Sylwester Nawrocki 2019-02-20  279  	if (ret < 0)
d832d2b2 Sylwester Nawrocki 2019-02-20  280  		return ret;
aba611fc Sylwester Nawrocki 2017-04-21  281  
bc3cf17b Sylwester Nawrocki 2019-02-14  282  	ret = snd_soc_of_get_dai_link_codecs(dev, codec, codec_link);
bc3cf17b Sylwester Nawrocki 2019-02-14  283  	if (ret < 0)
d832d2b2 Sylwester Nawrocki 2019-02-20  284  		goto err_put_cpu_dai;
aba611fc Sylwester Nawrocki 2017-04-21  285  
bc3cf17b Sylwester Nawrocki 2019-02-14  286  	/* Set capture capability only for boards with the MAX98090 CODEC */
bc3cf17b Sylwester Nawrocki 2019-02-14  287  	if (codec_link->num_codecs > 1) {
bc3cf17b Sylwester Nawrocki 2019-02-14  288  		card->dai_link[0].dpcm_capture = 1;
bc3cf17b Sylwester Nawrocki 2019-02-14  289  		card->dai_link[1].dpcm_capture = 1;
bc3cf17b Sylwester Nawrocki 2019-02-14  290  	}
a8ad0c85 Sylwester Nawrocki 2017-08-04  291  
bc3cf17b Sylwester Nawrocki 2019-02-14  292  	priv->sclk_i2s = of_clk_get_by_name(cpu_dai, "i2s_opclk1");
a8ad0c85 Sylwester Nawrocki 2017-08-04  293  	if (IS_ERR(priv->sclk_i2s)) {
a8ad0c85 Sylwester Nawrocki 2017-08-04  294  		ret = PTR_ERR(priv->sclk_i2s);
d832d2b2 Sylwester Nawrocki 2019-02-20  295  		goto err_put_cpu_dai;
a8ad0c85 Sylwester Nawrocki 2017-08-04  296  	}
a8ad0c85 Sylwester Nawrocki 2017-08-04  297  
bc3cf17b Sylwester Nawrocki 2019-02-14 @298  	priv->clk_i2s_bus = of_clk_get_by_name(cpu_dai, "iis");
a8ad0c85 Sylwester Nawrocki 2017-08-04  299  	if (IS_ERR(priv->clk_i2s_bus)) {
a8ad0c85 Sylwester Nawrocki 2017-08-04  300  		ret = PTR_ERR(priv->clk_i2s_bus);
a8ad0c85 Sylwester Nawrocki 2017-08-04  301  		goto err_put_sclk;
a8ad0c85 Sylwester Nawrocki 2017-08-04  302  	}
bc3cf17b Sylwester Nawrocki 2019-02-14  303  	of_node_put(cpu_dai);
a8ad0c85 Sylwester Nawrocki 2017-08-04  304  
aba611fc Sylwester Nawrocki 2017-04-21  305  	ret = devm_snd_soc_register_card(dev, card);
aba611fc Sylwester Nawrocki 2017-04-21  306  	if (ret < 0) {
aba611fc Sylwester Nawrocki 2017-04-21  307  		dev_err(dev, "snd_soc_register_card() failed: %d\n", ret);
a8ad0c85 Sylwester Nawrocki 2017-08-04  308  		goto err_put_clk_i2s;
aba611fc Sylwester Nawrocki 2017-04-21  309  	}
aba611fc Sylwester Nawrocki 2017-04-21  310  
aba611fc Sylwester Nawrocki 2017-04-21  311  	return 0;
aba611fc Sylwester Nawrocki 2017-04-21  312  
a8ad0c85 Sylwester Nawrocki 2017-08-04  313  err_put_clk_i2s:
a8ad0c85 Sylwester Nawrocki 2017-08-04  314  	clk_put(priv->clk_i2s_bus);
a8ad0c85 Sylwester Nawrocki 2017-08-04  315  err_put_sclk:
a8ad0c85 Sylwester Nawrocki 2017-08-04  316  	clk_put(priv->sclk_i2s);
d832d2b2 Sylwester Nawrocki 2019-02-20  317  err_put_cpu_dai:
d832d2b2 Sylwester Nawrocki 2019-02-20  318  	of_node_put(cpu_dai);
bc3cf17b Sylwester Nawrocki 2019-02-14  319  	snd_soc_of_put_dai_link_codecs(codec_link);
aba611fc Sylwester Nawrocki 2017-04-21  320  	return ret;
aba611fc Sylwester Nawrocki 2017-04-21  321  }
aba611fc Sylwester Nawrocki 2017-04-21  322  

:::::: The code at line 298 was first introduced by commit
:::::: bc3cf17b575a7a97b4af7ddcf86133175da7a582 ASoC: samsung: odroid: Add support for secondary CPU DAI

:::::: TO: Sylwester Nawrocki <s.nawrocki at samsung.com>
:::::: CC: Mark Brown <broonie at kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 50875 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20190221/a07eca69/attachment-0001.gz>


More information about the Alsa-devel mailing list