ASoC: Intel: avs: Use struct_size for struct avs_modcfg_ext size

The struct avs_modcfg_ext structure has a flexible array member for the
pin_fmts array, and the size should be calculated using struct_size to
prevent the potential for overflow with the allocation.

Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20230303180457.2457069-1-jacob.e.keller@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Jacob Keller 2023-03-03 10:04:57 -08:00 committed by Mark Brown
parent fe15c26ee2
commit c9ef0fee3b
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -478,7 +478,7 @@ static int avs_modext_create(struct avs_dev *adev, struct avs_path_module *mod)
int ret, i;
num_pins = tcfg->generic.num_input_pins + tcfg->generic.num_output_pins;
cfg_size = sizeof(*cfg) + sizeof(*cfg->pin_fmts) * num_pins;
cfg_size = struct_size(cfg, pin_fmts, num_pins);
cfg = kzalloc(cfg_size, GFP_KERNEL);
if (!cfg)