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

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>

authored by

Jacob Keller and committed by
Mark Brown
c9ef0fee fe15c26e

+1 -1
+1 -1
sound/soc/intel/avs/path.c
··· 478 478 int ret, i; 479 479 480 480 num_pins = tcfg->generic.num_input_pins + tcfg->generic.num_output_pins; 481 - cfg_size = sizeof(*cfg) + sizeof(*cfg->pin_fmts) * num_pins; 481 + cfg_size = struct_size(cfg, pin_fmts, num_pins); 482 482 483 483 cfg = kzalloc(cfg_size, GFP_KERNEL); 484 484 if (!cfg)