Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Troy Mitchell <troy.mitchell@linux.spacemit.com>
Cc: linux-sound@vger.kernel.org, spacemit@lists.linux.dev
Subject: [bug report] ASoC: spacemit: add i2s support for K1 SoC
Date: Fri, 24 Oct 2025 14:25:40 +0300	[thread overview]
Message-ID: <aPtiNCZ_KBezL2Dr@stanley.mountain> (raw)

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

             reply	other threads:[~2025-10-24 11:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-24 11:25 Dan Carpenter [this message]
2025-10-24 11:37 ` [bug report] ASoC: spacemit: add i2s support for K1 SoC Troy Mitchell
2025-10-24 11:43   ` Dan Carpenter
2025-10-24 16:06     ` Alex Elder
2025-10-27  2:50       ` Troy Mitchell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aPtiNCZ_KBezL2Dr@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=spacemit@lists.linux.dev \
    --cc=troy.mitchell@linux.spacemit.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox