ALSA: hda: intel-nhlt: Correct the handling of fmt_config flexible array
PATCH 1/1 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 a864e8f159b13 ("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]>
--- sound/hda/intel-nhlt.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
sound/hda/intel-nhlt.c +7 -1
@@ -55,16 +55,22 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt)/* find max number of channels based on format_configuration */ if (fmt_configs->fmt_count) { +struct nhlt_fmt_cfg *fmt_cfg = fmt_configs->fmt_config; +dev_dbg (dev,"found %d format definitions\n" , fmt_configs->fmt_count);for (i =0 ; i < fmt_configs->fmt_count; i++) {struct wav_fmt_ext *fmt_ext; - fmt_ext = &fmt_configs->fmt_config[i].fmt_ext; + fmt_ext = &fmt_cfg->fmt_ext;if (fmt_ext->fmt.channels > max_ch) max_ch = fmt_ext->fmt.channels; + +/* Move to the next nhlt_fmt_cfg */ + fmt_cfg = (struct nhlt_fmt_cfg *)(fmt_cfg->config.caps + + fmt_cfg->config.size); }dev_dbg (dev,"max channels found %d\n" , max_ch); }else {
Signature · 1 line
2.37.2
Takashi Iwai
AppliedQuoted 10 lines · Peter Ujfalusi
The struct nhlt_format's
fmt_configis a flexible array, it must not be used as normal array.
When moving to the nextnhlt_fmt_cfgwe need to take into account the data behind the ->config.caps (indicated by ->config.size).Fixes a864e8f159b13 ("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]>
Thanks, applied now.
Takashi