Linux Sound subsystem development
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: Initialize status1 to fix uninitialized symbol errors
@ 2025-12-03  8:33 hariconscious
  2025-12-03  8:56 ` Takashi Iwai
  0 siblings, 1 reply; 9+ messages in thread
From: hariconscious @ 2025-12-03  8:33 UTC (permalink / raw)
  To: perex, tiwai, cristian.ciocaltea, cryolitia, franta-linux
  Cc: khalid, shuah, david.hunter.linux, linux-sound, linux-kernel,
	HariKrishna Sagala

From: HariKrishna Sagala <hariconscious@gmail.com>

Initialize 'status1' with a default value to resolve the static analysis
smatch reported error "uninitialized symbol 'status1'".
The 'status1' variable is used to create a buff using "kmemdup".
So, ensure to initialize the value before it is read.

Signed-off-by: HariKrishna Sagala <hariconscious@gmail.com>
---
This patch fixes the below smatch reported errors.
sound/usb/mixer_quirks.c:2462 snd_rme_rate_get() error: uninitialized symbol 'status1'.
sound/usb/mixer_quirks.c:2467 snd_rme_rate_get() error: uninitialized symbol 'status1'.
sound/usb/mixer_quirks.c:2472 snd_rme_rate_get() error: uninitialized symbol 'status1'.
sound/usb/mixer_quirks.c:2495 snd_rme_sync_state_get() error: uninitialized symbol 'status1'.
sound/usb/mixer_quirks.c:2501 snd_rme_sync_state_get() error: uninitialized symbol 'status1'.
sound/usb/mixer_quirks.c:2522 snd_rme_spdif_if_get() error: uninitialized symbol 'status1'.
sound/usb/mixer_quirks.c:2535 snd_rme_spdif_format_get() error: uninitialized symbol 'status1'.
sound/usb/mixer_quirks.c:2548 snd_rme_sync_source_get() error: uninitialized symbol 'status1'.

The below is the flow of 'status1' it is used before initialization.

snd_rme_rate_get -> status1 is uninitialized and passed
	snd_rme_get_status1 -> passed as is
		snd_rme_read_value -> passed as is
			snd_usb_ctl_msg -> created buf from status1 using kmemdup
				usb_control_msg -> sent buf for reading/writing

Description of "usb_control_msg", states as
" * @data: pointer to the data to send"

Later from Usb control request, dst buf is copied to src buf but usb
control msg request is made before initialization.

Thank you.

 sound/usb/mixer_quirks.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 828af3095b86..06903c5de087 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -2449,7 +2449,7 @@ static int snd_rme_get_status1(struct snd_kcontrol *kcontrol,
 static int snd_rme_rate_get(struct snd_kcontrol *kcontrol,
 			    struct snd_ctl_elem_value *ucontrol)
 {
-	u32 status1;
+	u32 status1 = 0;
 	u32 rate = 0;
 	int idx;
 	int err;
@@ -2483,7 +2483,7 @@ static int snd_rme_rate_get(struct snd_kcontrol *kcontrol,
 static int snd_rme_sync_state_get(struct snd_kcontrol *kcontrol,
 				  struct snd_ctl_elem_value *ucontrol)
 {
-	u32 status1;
+	u32 status1 = 0;
 	int idx = SND_RME_CLOCK_NOLOCK;
 	int err;
 
@@ -2513,7 +2513,7 @@ static int snd_rme_sync_state_get(struct snd_kcontrol *kcontrol,
 static int snd_rme_spdif_if_get(struct snd_kcontrol *kcontrol,
 				struct snd_ctl_elem_value *ucontrol)
 {
-	u32 status1;
+	u32 status1 = 0;
 	int err;
 
 	err = snd_rme_get_status1(kcontrol, &status1);
@@ -2526,7 +2526,7 @@ static int snd_rme_spdif_if_get(struct snd_kcontrol *kcontrol,
 static int snd_rme_spdif_format_get(struct snd_kcontrol *kcontrol,
 				    struct snd_ctl_elem_value *ucontrol)
 {
-	u32 status1;
+	u32 status1 = 0;
 	int err;
 
 	err = snd_rme_get_status1(kcontrol, &status1);
@@ -2539,7 +2539,7 @@ static int snd_rme_spdif_format_get(struct snd_kcontrol *kcontrol,
 static int snd_rme_sync_source_get(struct snd_kcontrol *kcontrol,
 				   struct snd_ctl_elem_value *ucontrol)
 {
-	u32 status1;
+	u32 status1 = 0;
 	int err;
 
 	err = snd_rme_get_status1(kcontrol, &status1);

base-commit: 4a26e7032d7d57c998598c08a034872d6f0d3945
-- 
2.43.0


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

end of thread, other threads:[~2025-12-03 13:34 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-03  8:33 [PATCH] ALSA: usb-audio: Initialize status1 to fix uninitialized symbol errors hariconscious
2025-12-03  8:56 ` Takashi Iwai
2025-12-03 11:01   ` HariKrishna Sagala
2025-12-03 11:09     ` Takashi Iwai
2025-12-03 11:22       ` HariKrishna Sagala
2025-12-03 11:50         ` Takashi Iwai
2025-12-03 12:01           ` HariKrishna Sagala
2025-12-03 12:54             ` Takashi Iwai
2025-12-03 13:34               ` HariKrishna Sagala

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