Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI check error: use of uninitialized value ‘be_rate’ #5293

Open
bardliao opened this issue Jan 14, 2025 · 0 comments
Open

CI check error: use of uninitialized value ‘be_rate’ #5293

bardliao opened this issue Jan 14, 2025 · 0 comments

Comments

@bardliao
Copy link
Collaborator

sound/soc/sof/ipc4-pcm.c: In function ‘sof_ipc4_pcm_dai_link_fixup_rate’:
sound/soc/sof/ipc4-pcm.c:641:27: error: use of uninitialized value ‘be_rate’ [CWE-457] [-Werror=analyzer-use-of-uninitialized-value]
  641 |                 rate->min = be_rate;
      |                 ~~~~~~~~~~^~~~~~~~~
  ‘sof_ipc4_pcm_dai_link_fixup_rate’: events 1-3
    |
    |  605 |         unsigned int be_rate;
    |      |                      ^~~~~~~
    |      |                      |
    |      |                      (1) region created on stack here
    |      |                      (2) capacity: 4 bytes
    |......
    |  608 |         if (WARN_ON_ONCE(!num_input_formats))
    |      |            ~          
    |      |            |
    |      |            (3) following ‘false’ branch...
    |
  ‘sof_ipc4_pcm_dai_link_fixup_rate’: event 4
    |
    |cc1:
    | (4): ...to here
    |
  ‘sof_ipc4_pcm_dai_link_fixup_rate’: events 5-11
    |
    |  615 |         for (i = 0; i < num_input_formats; i++) {
    |      |                     ~~^~~~~~~~~~~~~~~~~~~
    |      |                       |
    |      |                       (5) following ‘false’ branch (when ‘i >= num_input_formats’)...
    |......
    |  635 |         if (!fe_be_rate_match) {
    |      |            ~           
    |      |            |
    |      |            (6) ...to here
    |      |            (7) following ‘false’ branch (when ‘fe_be_rate_match == 0’)...
    |  636 |                 if (!single_be_rate) {
    |      |                    ~   
    |      |                    |
    |      |                    (8) ...to here
    |      |                    (9) following ‘true’ branch (when ‘single_be_rate != 0’)...
    |......
    |  641 |                 rate->min = be_rate;
    |      |                 ~~~~~~~~~~~~~~~~~~~
    |      |                           |
    |      |                           (10) ...to here
    |      |                           (11) use of uninitialized value ‘be_rate’ here
    |
sound/soc/sof/ipc4-pcm.c:641:27: error: use of uninitialized value ‘be_rate’ [CWE-457] [-Werror=analyzer-use-of-uninitialized-value]
  641 |                 rate->min = be_rate;
      |                 ~~~~~~~~~~^~~~~~~~~
  ‘sof_ipc4_pcm_dai_link_fixup’: events 1-4
    |
    |  648 | static int sof_ipc4_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd,
    |      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |            |
    |      |            (1) entry to ‘sof_ipc4_pcm_dai_link_fixup’
    |......
    |  662 |         if (!dai) {
    |      |            ~
    |      |            |
    |      |            (2) following ‘false’ branch (when ‘dai’ is non-NULL)...
    |......
    |  668 |         ipc4_copier = dai->private;
    |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |                     |
    |      |                     (3) ...to here
    |  669 |         if (!ipc4_copier) {
    |      |            ~
    |      |            |
    |      |            (4) following ‘false’ branch (when ‘ipc4_copier’ is non-NULL)...
    |
  ‘sof_ipc4_pcm_dai_link_fixup’: event 5
    |
    |cc1:
    | (5): ...to here
    |
  ‘sof_ipc4_pcm_dai_link_fixup’: event 6
    |
    |./include/sound/pcm.h:701:21:
    |  701 |              stream <= SNDRV_PCM_STREAM_LAST;           \
sound/soc/sof/ipc4-pcm.c:675:9: note: in expansion of macro ‘for_each_pcm_streams’
    |  675 |         for_each_pcm_streams(dir) {
    |      |         ^~~~~~~~~~~~~~~~~~~~
    |
  ‘sof_ipc4_pcm_dai_link_fixup’: event 7
    |
    |  676 |                 struct snd_soc_dapm_widget *w = snd_soc_dai_get_widget(cpu_dai, dir);
    |      |                                                 ^
    |      |                                                 |
    |      |                                                 (7) inlined call to ‘snd_soc_dai_get_widget’ from ‘sof_ipc4_pcm_dai_link_fixup’
    |
    +--> ‘snd_soc_dai_get_widget’: event 8
           |
           |./include/sound/soc-dai.h:483:27:
           |  483 |         return dai->stream[stream].widget;
           |      |                ~~~~~~~~~~~^~~~~~~~
           |      |                           |
           |      |                           (8) ...to here
           |
    <------+
    |
  ‘sof_ipc4_pcm_dai_link_fixup’: event 9
    |
    |sound/soc/sof/ipc4-pcm.c:707:15:
    |  707 |         ret = sof_ipc4_pcm_dai_link_fixup_rate(sdev, params, ipc4_copier);
    |      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    |      |               |
    |      |               (9) calling ‘sof_ipc4_pcm_dai_link_fixup_rate’ from ‘sof_ipc4_pcm_dai_link_fixup’
    |
    +--> ‘sof_ipc4_pcm_dai_link_fixup_rate’: events 10-13
           |
           |  595 | static int sof_ipc4_pcm_dai_link_fixup_rate(struct snd_sof_dev *sdev,
           |      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           |      |            |
           |      |            (10) entry to ‘sof_ipc4_pcm_dai_link_fixup_rate’
           |......
           |  605 |         unsigned int be_rate;
           |      |                      ~~~~~~~
           |      |                      |
           |      |                      (11) region created on stack here
           |      |                      (12) capacity: 4 bytes
           |......
           |  608 |         if (WARN_ON_ONCE(!num_input_formats))
           |      |            ~
           |      |            |
           |      |            (13) following ‘false’ branch...
           |
         ‘sof_ipc4_pcm_dai_link_fixup_rate’: event 14
           |
           |cc1:
           | (14): ...to here
           |
         ‘sof_ipc4_pcm_dai_link_fixup_rate’: events 15-21
           |
           |  615 |         for (i = 0; i < num_input_formats; i++) {
           |      |                     ~~^~~~~~~~~~~~~~~~~~~
           |      |                       |
           |      |                       (15) following ‘false’ branch (when ‘i >= num_input_formats’)...
           |......
           |  635 |         if (!fe_be_rate_match) {
           |      |            ~           
           |      |            |
           |      |            (16) ...to here
           |      |            (17) following ‘false’ branch (when ‘fe_be_rate_match == 0’)...
           |  636 |                 if (!single_be_rate) {
           |      |                    ~   
           |      |                    |
           |      |                    (18) ...to here
           |      |                    (19) following ‘true’ branch (when ‘single_be_rate != 0’)...
           |......
           |  641 |                 rate->min = be_rate;
           |      |                 ~~~~~~~~~~~~~~~~~~~
           |      |                           |
           |      |                           (20) ...to here
           |      |                           (21) use of uninitialized value ‘be_rate’ here
           |

This is bogus as ‘be_rate’ will always be assigned when i == 0 in the for loop. And the for loop starts with i == 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant