diff mbox series

ALSA: control_led - fix the stack usage (control element ops)

Message ID 20210414105858.1937710-1-perex@perex.cz (mailing list archive)
State Accepted
Commit 543f8d780867bdbd8b0792487fa1644d89faa19c
Headers show
Series ALSA: control_led - fix the stack usage (control element ops) | expand

Commit Message

Jaroslav Kysela April 14, 2021, 10:58 a.m. UTC
It's a bad idea to allocate big structures on the stack.
Mark the variables as static and add a note for the locking.

Fixes: 22d8de62f11b ("ALSA: control - add generic LED trigger module as the new control layer")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
---
 sound/core/control_led.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Takashi Iwai April 14, 2021, 12:23 p.m. UTC | #1
On Wed, 14 Apr 2021 12:58:58 +0200,
Jaroslav Kysela wrote:
> 
> It's a bad idea to allocate big structures on the stack.
> Mark the variables as static and add a note for the locking.
> 
> Fixes: 22d8de62f11b ("ALSA: control - add generic LED trigger module as the new control layer")
> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
> Cc: Nathan Chancellor <nathan@kernel.org>
> Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
> Signed-off-by: Jaroslav Kysela <perex@perex.cz>

Applied now (with a removal of the duplicated sign-off).

Thanks!


Takashi
Jaroslav Kysela April 14, 2021, 1:53 p.m. UTC | #2
Dne 14. 04. 21 v 14:23 Takashi Iwai napsal(a):
> On Wed, 14 Apr 2021 12:58:58 +0200,
> Jaroslav Kysela wrote:
>>
>> It's a bad idea to allocate big structures on the stack.
>> Mark the variables as static and add a note for the locking.
>>
>> Fixes: 22d8de62f11b ("ALSA: control - add generic LED trigger module as the new control layer")
>> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
>> Cc: Nathan Chancellor <nathan@kernel.org>
>> Cc: Takashi Sakamoto <o-takashi@sakamocchi.jp>
>> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
> 
> Applied now (with a removal of the duplicated sign-off).

Thank you.

					Jaroslav
diff mbox series

Patch

diff --git a/sound/core/control_led.c b/sound/core/control_led.c
index 93b201063c7d..25f57c14f294 100644
--- a/sound/core/control_led.c
+++ b/sound/core/control_led.c
@@ -94,11 +94,15 @@  static struct snd_ctl_led *snd_ctl_led_get_by_access(unsigned int access)
 	return &snd_ctl_leds[group];
 }
 
+/*
+ * A note for callers:
+ *   The two static variables info and value are protected using snd_ctl_led_mutex.
+ */
 static int snd_ctl_led_get(struct snd_ctl_led_ctl *lctl)
 {
+	static struct snd_ctl_elem_info info;
+	static struct snd_ctl_elem_value value;
 	struct snd_kcontrol *kctl = lctl->kctl;
-	struct snd_ctl_elem_info info;
-	struct snd_ctl_elem_value value;
 	unsigned int i;
 	int result;