Skip to content

Commit 2e6481a

Browse files
ujfalusitiwai
authored andcommitted
ALSA: hda: intel-nhlt: Correct the handling of fmt_config flexible array
The struct nhlt_format's fmt_config is a flexible array, it must not be used as normal array. When moving to the next nhlt_fmt_cfg we need to take into account the data behind the ->config.caps (indicated by ->config.size). Fixes: a864e8f ("ALSA: hda: intel-nhlt: verify config type") Signed-off-by: Peter Ujfalusi <[email protected]> Reviewed-by: Pierre-Louis Bossart <[email protected]> Reviewed-by: Jaska Uimonen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 3e7e04b commit 2e6481a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

sound/hda/intel-nhlt.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,22 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt)
5555

5656
/* find max number of channels based on format_configuration */
5757
if (fmt_configs->fmt_count) {
58+
struct nhlt_fmt_cfg *fmt_cfg = fmt_configs->fmt_config;
59+
5860
dev_dbg(dev, "found %d format definitions\n",
5961
fmt_configs->fmt_count);
6062

6163
for (i = 0; i < fmt_configs->fmt_count; i++) {
6264
struct wav_fmt_ext *fmt_ext;
6365

64-
fmt_ext = &fmt_configs->fmt_config[i].fmt_ext;
66+
fmt_ext = &fmt_cfg->fmt_ext;
6567

6668
if (fmt_ext->fmt.channels > max_ch)
6769
max_ch = fmt_ext->fmt.channels;
70+
71+
/* Move to the next nhlt_fmt_cfg */
72+
fmt_cfg = (struct nhlt_fmt_cfg *)(fmt_cfg->config.caps +
73+
fmt_cfg->config.size);
6874
}
6975
dev_dbg(dev, "max channels found %d\n", max_ch);
7076
} else {

0 commit comments

Comments
 (0)