Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable
@ 2024-10-14  9:55 Jack Yu
  2024-10-14 16:22 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Jack Yu @ 2024-10-14  9:55 UTC (permalink / raw)
  To: broonie@kernel.org, lgirdwood@gmail.com
  Cc: alsa-devel@alsa-project.org, lars@metafoo.de, Flove(HsinFu),
	Oder Chiou, Shuming [范書銘],
	Derek [方德義], Jack Yu

[-- Attachment #1: Type: text/plain, Size: 908 bytes --]

If det_mode is not 0, 3 or 5 then function will return
jack_type with an uninitialzed value.
Enhance switch case to prevent uninitialized variable issue.

Signed-off-by: Jack Yu <jack.yu@realtek.com>
---
 sound/soc/codecs/rt-sdw-common.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/rt-sdw-common.c b/sound/soc/codecs/rt-sdw-common.c
index a422da6cf702..9f51fec383f9 100644
--- a/sound/soc/codecs/rt-sdw-common.c
+++ b/sound/soc/codecs/rt-sdw-common.c
@@ -150,15 +150,15 @@ int rt_sdca_headset_detect(struct regmap *map, unsigned int entity_id)
 		goto io_error;
 
 	switch (det_mode) {
-	case 0x00:
-		jack_type = 0;
-		break;
 	case 0x03:
 		jack_type = SND_JACK_HEADPHONE;
 		break;
 	case 0x05:
 		jack_type = SND_JACK_HEADSET;
 		break;
+	default:
+		jack_type = 0;
+		break;
 	}
 
 	/* write selected_mode */
-- 
2.34.1


[-- Attachment #2: winmail.dat --]
[-- Type: application/ms-tnef, Size: 5546 bytes --]

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

end of thread, other threads:[~2024-10-14 16:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14  9:55 [PATCH v2] ASoC: rt-sdw-common: Enhance switch case to prevent uninitialized variable Jack Yu
2024-10-14 16:22 ` Mark Brown

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