]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ALSA: hda/ca0132: Fix buffer overflow in add_tuning_control
authorLucy Thrun <lucy.thrun@digital-rabbithole.de>
Tue, 10 Jun 2025 17:50:12 +0000 (19:50 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:25:54 +0000 (16:25 +0200)
[ Upstream commit a409c60111e6bb98fcabab2aeaa069daa9434ca0 ]

The 'sprintf' call in 'add_tuning_control' may exceed the 44-byte
buffer if either string argument is too long. This triggers a compiler
warning.
Replaced 'sprintf' with 'snprintf' to limit string lengths to prevent
overflow.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202506100642.95jpuMY1-lkp@intel.com/
Signed-off-by: Lucy Thrun <lucy.thrun@digital-rabbithole.de>
Link: https://patch.msgid.link/20250610175012.918-3-lucy.thrun@digital-rabbithole.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
sound/pci/hda/patch_ca0132.c

index d825fcce05eefca8582bd5abe03b4c3689ef7239..45b267c02a98972454997bcedb94d24863221609 100644 (file)
@@ -4399,7 +4399,7 @@ static int add_tuning_control(struct hda_codec *codec,
        }
        knew.private_value =
                HDA_COMPOSE_AMP_VAL(nid, 1, 0, type);
-       sprintf(namestr, "%s %s Volume", name, dirstr[dir]);
+       snprintf(namestr, sizeof(namestr), "%s %s Volume", name, dirstr[dir]);
        return snd_hda_ctl_add(codec, nid, snd_ctl_new1(&knew, codec));
 }