All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] ASoC: rt-sdw-common: Fix bit-wise or'ing of values into uninitialized variable ret
@ 2024-10-08 16:47 Colin Ian King
  2024-10-08 17:04 ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Colin Ian King @ 2024-10-08 16:47 UTC (permalink / raw)
  To: Oder Chiou, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Jack Yu, linux-sound
  Cc: kernel-janitors, linux-kernel

There are a handful of bit-wise or'ing of values into the uninitialized
variable ret resulting in garbage results. Fix this by ininitializing
ret to zero.

Fixes: bbca8e7050e0 ("ASoC: rt-sdw-common: Common functions for Realtek soundwire driver")
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
 sound/soc/codecs/rt-sdw-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/rt-sdw-common.c b/sound/soc/codecs/rt-sdw-common.c
index 9ed0e9855699..a422da6cf702 100644
--- a/sound/soc/codecs/rt-sdw-common.c
+++ b/sound/soc/codecs/rt-sdw-common.c
@@ -101,21 +101,21 @@ EXPORT_SYMBOL_GPL(rt_sdca_index_update_bits);
  * rt_sdca_btn_type - Decision of button type.
  *
  * @buffer: UMP message buffer.
  *
  * A button type will be returned regarding to buffer,
  * it returns zero if buffer cannot be recognized.
  */
 int rt_sdca_btn_type(unsigned char *buffer)
 {
 	u8 btn_type = 0;
-	int ret;
+	int ret = 0;
 
 	btn_type |= buffer[0] & 0xf;
 	btn_type |= (buffer[0] >> 4) & 0xf;
 	btn_type |= buffer[1] & 0xf;
 	btn_type |= (buffer[1] >> 4) & 0xf;
 
 	if (btn_type & BIT(0))
 		ret |= SND_JACK_BTN_2;
 	if (btn_type & BIT(1))
 		ret |= SND_JACK_BTN_3;
-- 
2.39.5


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

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

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 16:47 [PATCH][next] ASoC: rt-sdw-common: Fix bit-wise or'ing of values into uninitialized variable ret Colin Ian King
2024-10-08 17:04 ` Mark Brown
2024-10-08 18:28   ` Dan Carpenter
2024-10-09  2:16   ` Jack Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.