Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ALSA: hda: cs35l56: Fix uninitialized value in cs35l56_hda_read_acpi()

Eliminate the uninitialized 'nval' in cs35l56_hda_read_acpi() if a
system-specific quirk overrides processing of the dev-index property.
The value is now stored in a new 'num_amps' member of struct cs35l56_hda
so that the quirk handler can set the value.

The quirk for the Lenovo Yoga Book 9i GenX replaces the values from the
dev-index property with hardcoded indexes. So cs35l56_hda_read_acpi() would
then skip reading the property. But this left the 'nval' local variable
uninitialized when it is later passed to cirrus_scodec_get_speaker_id().

Fixes: 40b1c2f9b299 ("ALSA: hda/cs35l56: Workaround bad dev-index on Lenovo Yoga Book 9i GenX")
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/linux-sound/aenFesLAStjrVNy8@stanley.mountain/T/#u
Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Link: https://patch.msgid.link/20260428130531.169600-1-rf@opensource.cirrus.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>

authored by

Richard Fitzgerald and committed by
Takashi Iwai
90df4957 b0e2333a

+8 -5
+7 -5
sound/hda/codecs/side-codecs/cs35l56_hda.c
··· 976 976 static int cs35l56_hda_fixup_yoga9(struct cs35l56_hda *cs35l56, int *bus_addr) 977 977 { 978 978 /* The cirrus,dev-index property has the wrong values */ 979 + cs35l56->num_amps = 2; 979 980 switch (*bus_addr) { 980 981 case 0x30: 981 982 cs35l56->index = 1; ··· 1026 1025 char hid_string[8]; 1027 1026 struct acpi_device *adev; 1028 1027 const char *property, *sub; 1029 - size_t nval; 1030 1028 int i, ret; 1031 1029 1032 1030 /* ··· 1061 1061 ret = -EINVAL; 1062 1062 goto err; 1063 1063 } 1064 - nval = ret; 1064 + cs35l56->num_amps = ret; 1065 1065 1066 - ret = device_property_read_u32_array(cs35l56->base.dev, property, values, nval); 1066 + ret = device_property_read_u32_array(cs35l56->base.dev, property, values, 1067 + cs35l56->num_amps); 1067 1068 if (ret) 1068 1069 goto err; 1069 1070 1070 - for (i = 0; i < nval; i++) { 1071 + for (i = 0; i < cs35l56->num_amps; i++) { 1071 1072 if (values[i] == id) { 1072 1073 cs35l56->index = i; 1073 1074 break; ··· 1091 1090 "Read ACPI _SUB failed(%ld): fallback to generic firmware\n", 1092 1091 PTR_ERR(sub)); 1093 1092 } else { 1094 - ret = cirrus_scodec_get_speaker_id(cs35l56->base.dev, cs35l56->index, nval, -1); 1093 + ret = cirrus_scodec_get_speaker_id(cs35l56->base.dev, cs35l56->index, 1094 + cs35l56->num_amps, -1); 1095 1095 if (ret == -ENOENT) { 1096 1096 cs35l56->system_name = sub; 1097 1097 } else if (ret >= 0) {
+1
sound/hda/codecs/side-codecs/cs35l56_hda.h
··· 26 26 struct work_struct dsp_work; 27 27 28 28 int index; 29 + int num_amps; 29 30 const char *system_name; 30 31 const char *amp_name; 31 32