ASoC: SOF: ipc4-topology: Fix use of unitialized value#5316
ASoC: SOF: ipc4-topology: Fix use of unitialized value#5316dbaluta wants to merge 1 commit intothesofproject:topic/sof-devfrom dbaluta:fix_warn
Conversation
Initialize ref_params to zero in order to fix static analyzer error: ipc4-topology.c: In function ‘sof_ipc4_prepare_copier_module’: ipc4-topology.c:1810:34: error: use of uninitialized value ‘((int *)<unknown>)[2]’ [CWE-457] [-Werror=analyzer-use-of-uninitialized-value] struct snd_pcm_hw_params ref_params; Note that this is a false positive, as manually inspecting the code there is no path where ref_params is used uninitialized. Fixes: f920964 ("ASoC: SOF: ipc4-topology: Correct DAI copier config and NHLT blob request") Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
| struct sof_ipc4_copier_data *copier_data; | ||
| int input_fmt_index, output_fmt_index; | ||
| struct snd_pcm_hw_params ref_params; | ||
| struct snd_pcm_hw_params ref_params = { 0 }; |
There was a problem hiding this comment.
This is so false report, I have refused to fix it out of principle ;)
ref_params is going to be initialized and when it is not we will just return with -EINVAL.
See the first switch (swidget->id) cases...
There was a problem hiding this comment.
Yes, this is a false positive. I wonder if we can mark it somehow so that the CI report
build test / GCC static -fanalyzer (pull_request) Failing after 3m
would be useful.
There was a problem hiding this comment.
if nothing else we should take this patch..
There was a problem hiding this comment.
@ujfalusi i noticed that there are at least 3-4 cases of similar false positives mostly in @thesofproject/amd code.
I have no strong preference or merging this patch.
Cc: @ranj063 @lgirdwood if you consider this useful you can merge it.
There was a problem hiding this comment.
@dbaluta, fwiw, with
$ gcc --version
gcc (GCC) 14.2.1 20240910
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-fanalyzer no longer reports false positive for this.
There was a problem hiding this comment.
@ujfalusi that's good news.
We are already using latest ubuntu, so at some point in the future the compiler version will be upgraded
Would anyone care to use a newer compiler version in .github/workflows/buildtest.yml?
There was a problem hiding this comment.
I wish we can switch to newer compiler version. :)
There was a problem hiding this comment.
I'll try to figure this out
|
Will close this and mark it as known issue. |
|
It also triggers with gcc-14 and by adding and btw, if this is 'fixed' then the gcc static analyzer will fail in |
Uh oh!
There was an error while loading. Please reload this page.