alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] alsa: control_led - fix initialization in the mode show callback
@ 2021-06-14  7:17 Jaroslav Kysela
  2021-06-14  7:52 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Jaroslav Kysela @ 2021-06-14  7:17 UTC (permalink / raw)
  To: ALSA development; +Cc: Takashi Iwai

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(-)

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;
-- 
2.30.2

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

* Re: [PATCH] alsa: control_led - fix initialization in the mode show callback
  2021-06-14  7:17 [PATCH] alsa: control_led - fix initialization in the mode show callback Jaroslav Kysela
@ 2021-06-14  7:52 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2021-06-14  7:52 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: ALSA development

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

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

end of thread, other threads:[~2021-06-14  7:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14  7:17 [PATCH] alsa: control_led - fix initialization in the mode show callback Jaroslav Kysela
2021-06-14  7:52 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).