ALSA: control-led: use strscpy in set_led_id()
authorJaroslav Kysela <perex@perex.cz>
Mon, 9 Jan 2023 15:12:49 +0000 (16:12 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:48:46 +0000 (11:48 +0100)
commit9ab3696881ca096939db8bfabdc98d0808bafdb2
treeb8e25a598f1e032a7a489267830df4cb1ce57c70
parenta8acfe2c6fb99f9375a9325807a179cd8c32e6e3
ALSA: control-led: use strscpy in set_led_id()

commit 70051cffb31b5ee09096351c3b41fcae6f89de31 upstream.

The use of strncpy() in the set_led_id() was incorrect.
The len variable should use 'min(sizeof(buf2) - 1, count)'
expression.

Use strscpy() function to simplify things and handle the error gracefully.

Fixes: a135dfb5de15 ("ALSA: led control - add sysfs kcontrol LED marking layer")
Reported-by: yang.yang29@zte.com.cn
Link: https://lore.kernel.org/alsa-devel/202301091945513559977@zte.com.cn/
Cc: <stable@vger.kernel.org>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/core/control_led.c