From: Jacob Keller Date: Fri, 3 Mar 2023 18:04:57 +0000 (-0800) Subject: ASoC: Intel: avs: Use struct_size for struct avs_modcfg_ext size X-Git-Tag: v6.6.7~2882^2~8^2~181 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c9ef0fee3bdf8197538aadc728e475fceba113bb;p=platform%2Fkernel%2Flinux-starfive.git 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 Reviewed-by: "Amadeusz Sławiński" Signed-off-by: Jacob Keller Link: https://lore.kernel.org/r/20230303180457.2457069-1-jacob.e.keller@intel.com Signed-off-by: Mark Brown --- diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index 05302ab..adbe23a 100644 --- a/sound/soc/intel/avs/path.c +++ b/sound/soc/intel/avs/path.c @@ -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)