Skip to contentSkip to conversation

alsa: control_led - fix initialization in the mode show callback

PATCH Applied Jaroslav Kysela 2 participants 2 messages Jun 14, 2021 Sound

lore
Share & tools
lore

Jaroslav Kysela

author maintainer
#0 lore raw

PATCH 1/1 alsa: control_led - fix initialization in the mode show callback

The str variable should be always initialized before use even if the switch covers all cases. This is a minimalistic fix: Assign NULL, the sprintf() may print '(null)' if something is corrupted.

---
 sound/core/control_led.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/core/control_led.c +1 -1
index 861f71f2fab5..764058cc345d 100644
@@ -397,7 +397,7 @@ static ssize_t mode_show(struct device *dev,
 			 struct device_attribute *attr, char *buf)
 {
 	struct snd_ctl_led *led = container_of(dev, struct snd_ctl_led, dev);
-	const char *str;
+	const char *str = NULL;
 
 	switch (led->mode) {
 	case MODE_FOLLOW_MUTE:	str = "follow-mute"; break;
Signature · 1 line
2.30.2
Applied
#1 lore raw
Quoted 6 lines · Jaroslav Kysela

The str variable should be always initialized before use even if the switch covers all cases. This is a minimalistic fix: Assign NULL, the sprintf() may print '(null)' if something is corrupted.

Thanks, applied.

Takashi