From patchwork Fri Mar 3 18:04:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Keller, Jacob E" X-Patchwork-Id: 658789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 733E0C64EC4 for ; Fri, 3 Mar 2023 18:08:16 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 92404AEA; Fri, 3 Mar 2023 19:07:23 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 92404AEA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1677866893; bh=ZTXIbGPkTGNK/2+lsQ6jqCe7/vd0YMD7ToZtYNiFvkE=; h=From:To:Subject:Date:CC:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=i9cZ4yON6Frzqu0JXPNWYniMYn6NIN+BgpgmWHD1EZmzrL9XifhudyjC3pT5uOi6P map++dtaXGGDN036MVra7qVLYVMNsbyMZPA7vNaRA9qH0+KvQ3xn7GJqLoSJwd8VPm EH/THNHPra+dCrPzEjX036pf2vygUPwqPhQQfNu0= Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 4C47EF800BA; Fri, 3 Mar 2023 19:07:01 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id EB7D1F80266; Fri, 3 Mar 2023 19:06:56 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 9E870F800BA for ; Fri, 3 Mar 2023 19:06:53 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 9E870F800BA Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=XvIkXRaC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1677866814; x=1709402814; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ZTXIbGPkTGNK/2+lsQ6jqCe7/vd0YMD7ToZtYNiFvkE=; b=XvIkXRaCpALEg3Kc3jE3npJyklv7G0gqLsBBVMoex5/OXdYUmsAtnP6M wwt1isl3pKQh1TFK93PCO/Ezh4Rtamm3TiazEOoHqDjJCWmeLhTmugnGP JRNTWFn9tCYYgoyqxzThIf1qarg94lKoGteSOEM+swhGR9oHqWt+hH723 VUHEx/JMAwfkjBKksLJVcAtLKx3M2jpfjBJUghq+cfOsQnddVcnHVUNZq JBqDEOQKg8MwRsmThFI2/YV1I9FVU0BgWoUNTESkQ6wzY2d6R30Roh+It FBhcmBC/JGCnHzjROF5K6mZtqZShW7nAEgofHSKnVzq5WSgORHlA56z1Y Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="421382219" X-IronPort-AV: E=Sophos;i="5.98,231,1673942400"; d="scan'208";a="421382219" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2023 10:05:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10638"; a="652876168" X-IronPort-AV: E=Sophos;i="5.98,231,1673942400"; d="scan'208";a="652876168" Received: from jekeller-desk.amr.corp.intel.com (HELO jekeller-desk.jekeller.internal) ([10.166.241.1]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Mar 2023 10:05:02 -0800 From: Jacob Keller To: Mark Brown Subject: [PATCH v2] ASoC: Intel: avs: Use struct_size for struct avs_modcfg_ext size Date: Fri, 3 Mar 2023 10:04:57 -0800 Message-Id: <20230303180457.2457069-1-jacob.e.keller@intel.com> X-Mailer: git-send-email 2.39.1.405.gd4c25cc71f83 MIME-Version: 1.0 Message-ID-Hash: GLKI6DIVVHK57B6Y72RZ45LN5XU7OLZ3 X-Message-ID-Hash: GLKI6DIVVHK57B6Y72RZ45LN5XU7OLZ3 X-MailFrom: jacob.e.keller@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Cezary Rojewski , alsa-devel@alsa-project.org, Jacob Keller , =?utf-8?q?Amadeusz_S=C5=82awi?= =?utf-8?q?=C5=84ski?= X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: <> List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- sound/soc/intel/avs/path.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: ee3f96b164688dae21e2466a57f2e806b64e8a37 diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c index 05302ab705ae..adbe23a47847 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)