From nobody Mon Feb 9 03:46:26 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=arm.com Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1661349409653139.54487612124763; Wed, 24 Aug 2022 06:56:49 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.392672.631222 (Exim 4.92) (envelope-from ) id 1oQqrs-0007Vy-JR; Wed, 24 Aug 2022 13:56:28 +0000 Received: by outflank-mailman (output) from mailman id 392672.631222; Wed, 24 Aug 2022 13:56:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oQqrs-0007Vm-DR; Wed, 24 Aug 2022 13:56:28 +0000 Received: by outflank-mailman (input) for mailman id 392672; Wed, 24 Aug 2022 13:56:27 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oQqrr-0005xm-9r for xen-devel@lists.xenproject.org; Wed, 24 Aug 2022 13:56:27 +0000 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by se1-gles-flk1.inumbo.com (Halon) with ESMTP id 7cf531a8-23b4-11ed-9250-1f966e50362f; Wed, 24 Aug 2022 15:56:01 +0200 (CEST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0DCA11042; Wed, 24 Aug 2022 06:56:30 -0700 (PDT) Received: from e109506.cambridge.arm.com (e109506.cambridge.arm.com [10.1.199.62]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 27DA83FAF5; Wed, 24 Aug 2022 06:56:25 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 7cf531a8-23b4-11ed-9250-1f966e50362f From: Rahul Singh To: xen-devel@lists.xenproject.org Cc: Bertrand Marquis , Stefano Stabellini , Julien Grall , Volodymyr Babchuk Subject: [PATCH 10/10] xen/arm: smmuv3: Avoid open coded arithmetic in memory allocation Date: Wed, 24 Aug 2022 14:53:14 +0100 Message-Id: <077dda72f2e43ae0ea5794f4d403eddd225c87e4.1661331102.git.rahul.singh@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1661349412891100001 Content-Type: text/plain; charset="utf-8" Backport Linux commit 98b64741d61124a12fb05a7595acb1fd6c1dc55d "iommu/arm-smmu-v3: Avoid open coded arithmetic in memory allocation" Original commit message: iommu/arm-smmu-v3: Avoid open coded arithmetic in memory allocation kmalloc_array()/kcalloc() should be used to avoid potential overflow when a multiplication is needed to compute the size of the requested memory. So turn a devm_kzalloc()+explicit size computation into an equivalent devm_kcalloc(). Signed-off-by: Christophe JAILLET Acked-by: Robin Murphy Link: https://lore.kernel.org/r/3f7b9b202c6b6f5edc234ab7af5f208fbf8bc94= 4.1644274051.git.christophe.jaillet@wanadoo.fr Signed-off-by: Will Deacon Signed-off-by: Rahul Singh --- xen/drivers/passthrough/arm/smmu-v3.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthroug= h/arm/smmu-v3.c index 900149d0fa..e074d7806f 100644 --- a/xen/drivers/passthrough/arm/smmu-v3.c +++ b/xen/drivers/passthrough/arm/smmu-v3.c @@ -1929,10 +1929,10 @@ static int arm_smmu_init_l1_strtab(struct arm_smmu_= device *smmu) { unsigned int i; struct arm_smmu_strtab_cfg *cfg =3D &smmu->strtab_cfg; - size_t size =3D sizeof(*cfg->l1_desc) * cfg->num_l1_ents; void *strtab =3D smmu->strtab_cfg.strtab; =20 - cfg->l1_desc =3D _xzalloc(size, sizeof(void *)); + cfg->l1_desc =3D _xzalloc_array(sizeof(*cfg->l1_desc), sizeof(void *), + cfg->num_l1_ents); if (!cfg->l1_desc) return -ENOMEM; =20 --=20 2.25.1