mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: initialize variables that could ignore errors
@ 2022-01-26 18:21 trix
  2022-01-27 13:41 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2022-01-26 18:21 UTC (permalink / raw)
  To: perex, tiwai, nathan, ndesaulniers, kai.heng.feng, jiapeng.chong,
	giun7a, colin.king
  Cc: alsa-devel, linux-kernel, llvm, Tom Rix

From: Tom Rix <trix@redhat.com>

clang static analysis reports this representative issue
mixer.c:1548:35: warning: Assigned value is garbage or undefined
        ucontrol->value.integer.value[0] = val;
                                         ^ ~~~

The filter_error() macro allows errors to be ignored.
If errors can be ignored, initialize variables
so garbage will not be used.

Fixes: 48cc42973509 ("ALSA: usb-audio: Filter error from connector kctl ops, too")
Signed-off-by: Tom Rix <trix@redhat.com>
---
 sound/usb/mixer.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
index e8f3f8d622ec5..630766ba259fd 100644
--- a/sound/usb/mixer.c
+++ b/sound/usb/mixer.c
@@ -1527,6 +1527,10 @@ static int get_connector_value(struct usb_mixer_elem_info *cval,
 		usb_audio_err(chip,
 			"cannot get connectors status: req = %#x, wValue = %#x, wIndex = %#x, type = %d\n",
 			UAC_GET_CUR, validx, idx, cval->val_type);
+
+		if (val)
+			*val = 0;
+
 		return filter_error(cval, ret);
 	}
 
-- 
2.26.3


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: usb-audio: initialize variables that could ignore errors
  2022-01-26 18:21 [PATCH] ALSA: usb-audio: initialize variables that could ignore errors trix
@ 2022-01-27 13:41 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2022-01-27 13:41 UTC (permalink / raw)
  To: trix
  Cc: perex, tiwai, nathan, ndesaulniers, kai.heng.feng, jiapeng.chong,
	giun7a, colin.king, alsa-devel, linux-kernel, llvm

On Wed, 26 Jan 2022 19:21:42 +0100,
trix@redhat.com wrote:
> 
> From: Tom Rix <trix@redhat.com>
> 
> clang static analysis reports this representative issue
> mixer.c:1548:35: warning: Assigned value is garbage or undefined
>         ucontrol->value.integer.value[0] = val;
>                                          ^ ~~~
> 
> The filter_error() macro allows errors to be ignored.
> If errors can be ignored, initialize variables
> so garbage will not be used.
> 
> Fixes: 48cc42973509 ("ALSA: usb-audio: Filter error from connector kctl ops, too")
> Signed-off-by: Tom Rix <trix@redhat.com>

Thanks, applied.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-27 13:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-26 18:21 [PATCH] ALSA: usb-audio: initialize variables that could ignore errors trix
2022-01-27 13:41 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®