diff mbox series

alsa: control_led - fix initialization in the mode show callback

Message ID 20210614071710.1786866-1-perex@perex.cz
State Accepted
Commit e381a14c3e3a4e90e293d4eaa5a3ab8ae98b9973
Headers show
Series alsa: control_led - fix initialization in the mode show callback | expand

Commit Message

Jaroslav Kysela June 14, 2021, 7:17 a.m. UTC
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.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
 sound/core/control_led.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Takashi Iwai June 14, 2021, 7:52 a.m. UTC | #1
On Mon, 14 Jun 2021 09:17:10 +0200,
Jaroslav Kysela wrote:
> 
> 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.
> 
> Signed-off-by: Jaroslav Kysela <perex@perex.cz>

Thanks, applied.


Takashi
diff mbox series

Patch

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 861f71f2fab5..764058cc345d 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -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;