From: Dan Carpenter <error27@gmail.com>
To: cezary.rojewski@intel.com
Cc: alsa-devel@alsa-project.org
Subject: [bug report] ALSA: hda: Interrupt servicing and BDL setup for compress streams
Date: Wed, 7 Dec 2022 17:28:30 +0300 [thread overview]
Message-ID: <Y5CjDmg5B/8J5Yim@kili> (raw)
Hello Cezary Rojewski,
The patch 3e9582267e3a: "ALSA: hda: Interrupt servicing and BDL setup
for compress streams" from Dec 2, 2022, leads to the following Smatch
static checker warning:
sound/hda/hdac_stream.c:544 snd_hdac_stream_setup_periods()
error: uninitialized symbol 'dmab'.
sound/hda/hdac_stream.c
487 int snd_hdac_stream_setup_periods(struct hdac_stream *azx_dev)
488 {
489 struct hdac_bus *bus = azx_dev->bus;
490 struct snd_pcm_substream *substream = azx_dev->substream;
491 struct snd_compr_stream *cstream = azx_dev->cstream;
492 struct snd_pcm_runtime *runtime = NULL;
493 struct snd_dma_buffer *dmab;
494 __le32 *bdl;
495 int i, ofs, periods, period_bytes;
496 int pos_adj, pos_align;
497
498 if (substream) {
499 runtime = substream->runtime;
500 dmab = snd_pcm_get_dma_buf(substream);
501 } else if (cstream) {
502 dmab = snd_pcm_get_dma_buf(cstream);
503 }
dmab is not initialized on else path.
504
505 /* reset BDL address */
506 snd_hdac_stream_writel(azx_dev, SD_BDLPL, 0);
507 snd_hdac_stream_writel(azx_dev, SD_BDLPU, 0);
508
509 period_bytes = azx_dev->period_bytes;
510 periods = azx_dev->bufsize / period_bytes;
511
512 /* program the initial BDL entries */
513 bdl = (__le32 *)azx_dev->bdl.area;
514 ofs = 0;
515 azx_dev->frags = 0;
516
517 pos_adj = bus->bdl_pos_adj;
518 if (runtime && !azx_dev->no_period_wakeup && pos_adj > 0) {
519 pos_align = pos_adj;
520 pos_adj = DIV_ROUND_UP(pos_adj * runtime->rate, 48000);
521 if (!pos_adj)
522 pos_adj = pos_align;
523 else
524 pos_adj = roundup(pos_adj, pos_align);
525 pos_adj = frames_to_bytes(runtime, pos_adj);
526 if (pos_adj >= period_bytes) {
527 dev_warn(bus->dev, "Too big adjustment %d\n",
528 pos_adj);
529 pos_adj = 0;
530 } else {
531 ofs = setup_bdle(bus, dmab, azx_dev,
532 &bdl, ofs, pos_adj, true);
This is okay because runtime is set.
533 if (ofs < 0)
534 goto error;
535 }
536 } else
537 pos_adj = 0;
538
539 for (i = 0; i < periods; i++) {
540 if (i == periods - 1 && pos_adj)
541 ofs = setup_bdle(bus, dmab, azx_dev,
This is okay because pos_adj is checked.
542 &bdl, ofs, period_bytes - pos_adj, 0);
543 else
544 ofs = setup_bdle(bus, dmab, azx_dev,
^^^^
Potentially uninitialized?
545 &bdl, ofs, period_bytes,
546 !azx_dev->no_period_wakeup);
547 if (ofs < 0)
548 goto error;
549 }
550 return 0;
551
552 error:
553 dev_err(bus->dev, "Too many BDL entries: buffer=%d, period=%d\n",
554 azx_dev->bufsize, period_bytes);
555 return -EINVAL;
556 }
regards,
dan carpenter
next reply other threads:[~2022-12-07 14:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-07 14:28 Dan Carpenter [this message]
2022-12-07 14:35 ` [bug report] ALSA: hda: Interrupt servicing and BDL setup for compress streams Cezary Rojewski
2022-12-07 16:55 ` Takashi Iwai
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=Y5CjDmg5B/8J5Yim@kili \
--to=error27@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=cezary.rojewski@intel.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 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.