Hi,
Static analysis with Coverity has detected an uninitialized value being
used in a comparison. The error was detected on a recent change to
drivers/staging/greybus/audio_topology.c however the issue actually
dates back to the original commit:
commit 6339d2322c47f4b8ebabf9daf0130328ed72648b
Author: Vaibhav Agarwal <vaibhav.agarwal(a)linaro.org>
Date: Wed Jan 13 14:07:51 2016 -0700
greybus: audio: Add topology parser for GB codec
The analysis is as follows:
425 static int gbcodec_mixer_dapm_ctl_put(struct snd_kcontrol *kcontrol,
426 struct snd_ctl_elem_value
*ucontrol)
427 {
428 int ret, wi, max, connect;
429 unsigned int mask, val;
430 struct gb_audio_ctl_elem_info *info;
431 struct gbaudio_ctl_pvt *data;
1. var_decl: Declaring variable gbvalue without initializer.
432 struct gb_audio_ctl_elem_value gbvalue;
433 struct gbaudio_module_info *module;
434 struct snd_soc_dapm_widget_list *wlist =
snd_kcontrol_chip(kcontrol);
435 struct snd_soc_dapm_widget *widget = wlist->widgets[0];
436 struct device *codec_dev = widget->dapm->dev;
437 struct gbaudio_codec_info *gb = dev_get_drvdata(codec_dev);
438 struct gb_bundle *bundle;
439
2. Condition 0 /* __builtin_types_compatible_p() */, taking false branch.
3. Condition 1 /* __builtin_types_compatible_p() */, taking true branch.
4. Falling through to end of if statement.
5. Condition !!branch, taking false branch.
6. Condition ({...; !!branch;}), taking false branch.
440 dev_dbg(codec_dev, "Entered %s:%s\n", __func__,
kcontrol->id.name);
441 module = find_gb_module(gb, kcontrol->id.name);
7. Condition !module, taking false branch.
442 if (!module)
443 return -EINVAL;
444
445 data = (struct gbaudio_ctl_pvt *)kcontrol->private_value;
446 info = (struct gb_audio_ctl_elem_info *)data->info;
8. Condition 0 /* !!(!__builtin_types_compatible_p() &&
!__builtin_types_compatible_p()) */, taking false branch.
447 bundle = to_gb_bundle(module->dev);
448
9. Condition data->vcount == 2, taking true branch.
449 if (data->vcount == 2)
450 dev_warn(widget->dapm->dev,
451 "GB: Control '%s' is stereo, which is not
supported\n",
452 kcontrol->id.name);
453
454 max = le32_to_cpu(info->value.integer.max);
455 mask = (1 << fls(max)) - 1;
456 val = ucontrol->value.integer.value[0] & mask;
10. Condition !!val, taking true branch.
457 connect = !!val;
458
459 /* update ucontrol */
Uninitialized scalar variable (UNINIT)
11. uninit_use: Using uninitialized value gbvalue.value.integer_value[0].
460 if (gbvalue.value.integer_value[0] != val) {
The gbvalue.value.integer_value[0] read is bogus since gbvalue was
declared on the stack but was not initialized. There seems to be no
where that sets this data. I'm assuming most of the time that the
comparison works because the garbage value is different from val and so
the code in the if stanza is executed.
Anyhow, I'm unsure what the original intent of the code was, so I've not
attempted to fix this.
Colin
The existing GB Audio codec driver is dependent on MSM8994 Audio driver.
During the development stage, this dependency was configured due to
various changes involved in MSM Audio driver to enable addtional codec
card and some of the changes proposed in mainline ASoC framework.
However, these are not the real dependencies and some of them can be
easily removed.
The folowing patch series includes the changes to resolve unnecessary
depedencies and make the codec driver functional with the latest kernel.
Patch 1,2: Incudes jack framework related changes.
Patch 3,4,5: Resolves compilation error observed with the latest kernel and
also provides helper APIs required to allow dynamic addition/removal of
modules.
Patch 6: Finally provides config options and related Makefile changes to
enable GB Codec driver.
Thanks to Alexandre for raising the headsup [1] and motivating me to provide
the necessary changes.
This patchset is intended to resolve the componentization issue only.
And as per the suggestion [2] from Mark, I'll share a separate patch series
aligned to ASoC tree. Once the relevant changes are accepted in snd-soc
framework, I'll share relevant patches to pull GB Audio out of the
staging tree.
v1:
- Include the changes for the review comments suggested by Dan
- Rebase to latest staging-next
v2:
- Avoid defining unused 'update' pointer
- Fix the missing connect bool value required during mixer_update_power
- Added Reviewed-by tag from Dan
- Rebase to latest staging-next
v3:
- Fix the warnings reported by lkp[3]
- Rebase to latest staging-next
[1] https://lore.kernel.org/lkml/20200507212912.599433-1-alexandre.belloni@boot…
[2] https://lore.kernel.org/alsa-devel/20200612160620.GK5396@sirena.org.uk/
[3] https://lore.kernel.org/lkml/202006200150.mNVj1Duq%25lkp@intel.com/
Vaibhav Agarwal (7):
staging: greybus: audio: Update snd_jack FW usage as per new APIs
staging: greybus: audio: Maintain jack list within GB Audio module
staging: greybus: audio: Resolve compilation errors for GB codec
module
staging: greybus: audio: Resolve compilation error in topology parser
staging: greybus: audio: Add helper APIs for dynamic audio modules
staging: greybus: audio: Enable GB codec, audio module compilation.
drivers: staging: audio: Fix the missing header file for helper file
drivers/staging/greybus/Kconfig | 14 +-
drivers/staging/greybus/Makefile | 6 +-
drivers/staging/greybus/audio_codec.c | 178 +++++++++++---------
drivers/staging/greybus/audio_codec.h | 12 +-
drivers/staging/greybus/audio_helper.c | 198 +++++++++++++++++++++++
drivers/staging/greybus/audio_helper.h | 17 ++
drivers/staging/greybus/audio_module.c | 15 +-
drivers/staging/greybus/audio_topology.c | 131 +++++++--------
8 files changed, 414 insertions(+), 157 deletions(-)
create mode 100644 drivers/staging/greybus/audio_helper.c
create mode 100644 drivers/staging/greybus/audio_helper.h
base-commit: 14442181d20490945f341644bb8257e334b01447
--
2.27.0
Hi list,
I made a PR to GitHub before realizing that it's probably preferred to send
a patch to the ML.
https://github.com/projectara/manifesto/pull/1
Patch is attached as well.
Is anyone able to merge the PR or patch?
Thanks,
C
The existing GB Audio codec driver is dependent on MSM8994 Audio driver.
During the development stage, this dependency was configured due to
various changes involved in MSM Audio driver to enable addtional codec
card and some of the changes proposed in mainline ASoC framework.
However, these are not the real dependencies and some of them can be
easily removed.
The folowing patch series includes the changes to resolve unnecessary
depedencies and make the codec driver functional with the latest kernel.
Patch 1,2: Incudes jack framework related changes.
Patch 3,4,5: Resolves compilation error observed with the latest kernel and
also provides helper APIs required to allow dynamic addition/removal of
modules.
Patch 6: Finally provides config options and related Makefile changes to
enable GB Codec driver.
Thanks to Alexandre for raising the headsup [1] and motivating me to provide
the necessary changes.
This patchset is intended to resolve the componentization issue only.
And as per the suggestion [2] from Mark, I'll share a separate patch series
aligned to ASoC tree. Once the relevant changes are accepted in snd-soc
framework, I'll share relevant patches to pull GB Audio out of the
staging tree.
[1] https://lore.kernel.org/lkml/20200507212912.599433-1-alexandre.belloni@boot…
[2] https://lore.kernel.org/alsa-devel/20200612160620.GK5396@sirena.org.uk/
v1:
- Include the changes for the review comments suggested by Dan
- Rebase to latest staging-next
v2:
- Avoid defining unused 'update' pointer
- Fix the missing connect bool value required during mixer_update_power
- Added Reviewed-by tag from Dan
- Rebase to latest staging-next
Vaibhav Agarwal (6):
staging: greybus: audio: Update snd_jack FW usage as per new APIs
staging: greybus: audio: Maintain jack list within GB Audio module
staging: greybus: audio: Resolve compilation errors for GB codec
module
staging: greybus: audio: Resolve compilation error in topology parser
staging: greybus: audio: Add helper APIs for dynamic audio modules
staging: greybus: audio: Enable GB codec, audio module compilation.
drivers/staging/greybus/Kconfig | 14 +-
drivers/staging/greybus/Makefile | 6 +-
drivers/staging/greybus/audio_codec.c | 178 +++++++++++---------
drivers/staging/greybus/audio_codec.h | 12 +-
drivers/staging/greybus/audio_helper.c | 197 +++++++++++++++++++++++
drivers/staging/greybus/audio_helper.h | 17 ++
drivers/staging/greybus/audio_module.c | 15 +-
drivers/staging/greybus/audio_topology.c | 123 +++++++-------
8 files changed, 409 insertions(+), 153 deletions(-)
create mode 100644 drivers/staging/greybus/audio_helper.c
create mode 100644 drivers/staging/greybus/audio_helper.h
base-commit: 98fe05e21a6e0ca242e974650ed58b64813cb2dc
--
2.26.2