Linux Sound subsystem development
 help / color / mirror / Atom feed
* [bug report] ASoC: spacemit: add i2s support for K1 SoC
@ 2025-10-24 11:25 Dan Carpenter
  2025-10-24 11:37 ` Troy Mitchell
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2025-10-24 11:25 UTC (permalink / raw)
  To: Troy Mitchell; +Cc: linux-sound, spacemit

Hello Troy Mitchell,

Commit fce217449075 ("ASoC: spacemit: add i2s support for K1 SoC")
from Oct 17, 2025 (linux-next), leads to the following Smatch static
checker warning:

	sound/soc/spacemit/k1_i2s.c:435 spacemit_i2s_probe()
	error: uninitialized symbol 'dai'.

sound/soc/spacemit/k1_i2s.c
    389 static int spacemit_i2s_probe(struct platform_device *pdev)
    390 {
    391         struct snd_soc_dai_driver *dai;
    392         struct spacemit_i2s_dev *i2s;
    393         struct resource *res;
    394         struct clk *clk;
    395         int ret;
    396 
    397         i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL);
    398         if (!i2s)
    399                 return -ENOMEM;
    400 
    401         i2s->dev = &pdev->dev;
    402 
    403         i2s->sysclk = devm_clk_get_enabled(i2s->dev, "sysclk");
    404         if (IS_ERR(i2s->sysclk))
    405                 return dev_err_probe(i2s->dev, PTR_ERR(i2s->sysclk),
    406                                      "failed to enable sysbase clock\n");
    407 
    408         i2s->bclk = devm_clk_get_enabled(i2s->dev, "bclk");
    409         if (IS_ERR(i2s->bclk))
    410                 return dev_err_probe(i2s->dev, PTR_ERR(i2s->bclk), "failed to enable bit clock\n");
    411 
    412         clk = devm_clk_get_enabled(i2s->dev, "sspa_bus");
    413         if (IS_ERR(clk))
    414                 return dev_err_probe(i2s->dev, PTR_ERR(clk), "failed to enable sspa_bus clock\n");
    415 
    416         i2s->sspa_clk = devm_clk_get_enabled(i2s->dev, "sspa");
    417         if (IS_ERR(clk))
    418                 return dev_err_probe(i2s->dev, PTR_ERR(clk), "failed to enable sspa clock\n");
    419 
    420         i2s->base = devm_platform_get_and_ioremap_resource(pdev, 0, &res);
    421         if (IS_ERR(i2s->base))
    422                 return dev_err_probe(i2s->dev, PTR_ERR(i2s->base), "failed to map registers\n");
    423 
    424         i2s->reset = devm_reset_control_get_exclusive(&pdev->dev, NULL);
    425         if (IS_ERR(i2s->reset))
    426                 return dev_err_probe(i2s->dev, PTR_ERR(i2s->reset),
    427                                      "failed to get reset control");
    428 
    429         dev_set_drvdata(i2s->dev, i2s);
    430 
    431         spacemit_i2s_init_dai(i2s, &dai, res->start + SSDATR);
                                           ^^^^
dai is not initialized on failure.  Generally in the kernel we always
check for allocation failures.  Even when they can't happen in real life.
I was hoping they were going to make a rule that allocations under 4k
wouldn't have to be checked but it hasn't happened yet.

    432 
    433         ret = devm_snd_soc_register_component(i2s->dev,
    434                                               &spacemit_i2s_component,
--> 435                                               dai, 1);
    436         if (ret)
    437                 return dev_err_probe(i2s->dev, ret, "failed to register component");
    438 
    439         return devm_snd_dmaengine_pcm_register(&pdev->dev, &spacemit_dmaengine_pcm_config, 0);
    440 }

regards,
dan carpenter

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

end of thread, other threads:[~2025-10-27  2:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24 11:25 [bug report] ASoC: spacemit: add i2s support for K1 SoC Dan Carpenter
2025-10-24 11:37 ` Troy Mitchell
2025-10-24 11:43   ` Dan Carpenter
2025-10-24 16:06     ` Alex Elder
2025-10-27  2:50       ` Troy Mitchell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox