Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13032724rwd; Fri, 23 Jun 2023 14:39:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4b5uBUdomuyamwNu2Ko/17Wb2EJgscEzR9qvOW5lhSCm7xxU/3YNmPkHlnKunX9mtaNuCO X-Received: by 2002:a05:6a20:938b:b0:e9:5b0a:deff with SMTP id x11-20020a056a20938b00b000e95b0adeffmr22901742pzh.22.1687556369329; Fri, 23 Jun 2023 14:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556369; cv=none; d=google.com; s=arc-20160816; b=Vr5oztIrruG9HrGzkSEycgCVTS+hfu26y7vTfn+7eCcov5Qwpu+KrjGhw+kHz+hblC yZskEEyhJ8+hWdEod2oUpdM++dBz8Y1iXBsG/nNy31/IhlfGeUXRrFXmfqOeFzEdBpXp L4I8BpVdmYM8clqrSHb32zMWr9NADjkV1xtadriv3sJ0ighpS+/kGORf9g0t718sKMBM CQ360IcdsR0ClyLb/RqOyQxv6BIOh9PxMz4R2J5OBfcV6Yv9FSGbF+V2BlTiF2FgXs// hwkkkFcb0sn2YDcMyKdlfAtdbG4GvU+QKod72DaIF+H6BnmyBrXy9aMEnWggCm39w+al oSAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1HkDEW7AxSHLZvHADInYpWBN1+Bsf50V6Er9x8KFaJk=; fh=yHGuOWQHbttm9lF3oiSFhqz9m993m7B7c90zxZrRrzA=; b=MCt9/W2TVBdpChF/kmA+I1QeKuiCp7R7pJT14HGPCuQjyXkrhJkKT2PAioJNPB2Zeh nVNKWxUL/uOiSE/avacAdNLYcdRbLOmp4ns+ZeZxtR23qtNoLGbDiJ0Hz3WMOBDil3bo z3jCt5YBUF+oF708ebgJMrX7TxalsWfUU9LMwFF80ml8IKwDfJoEqOCPebADMwhP66Jw jxD97oilyq7TCAI8ia3A7am/mqYDH8SbwPTq0nPSzCg1R3q3fqhR/tzdq5w2nGmQbuhQ pMBhv9koONWQWahgHB0gZBlrxJWrr/ifsKunsQCGo/Y3rV5cqzDnL35KWEjMzrpdTq09 6IJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=BfrIEUyQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q14-20020a170902bd8e00b001ab1279d418si54564pls.474.2023.06.23.14.39.17; Fri, 23 Jun 2023 14:39:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=BfrIEUyQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232606AbjFWVPv (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232483AbjFWVPV (ORCPT ); Fri, 23 Jun 2023 17:15:21 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C8FD1997; Fri, 23 Jun 2023 14:15:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=1HkDEW7AxSHLZvHADInYpWBN1+Bsf50V6Er9x8KFaJk=; b=BfrIEUyQFLrGM984hWuTDVJ9BMp+YgtR3JEATuk5EkoZBafGGqyDRXjy GAn3Um4ZVQx9UGrkJUHaG/3M/yr6kZYJ19tAksbvEPhtIVa8nQg5SsDSO jtf7phSjQezrORoUWJ63Ez5TVQ12NuIb2JdR80iGNsvJm0dJOPwU7L6oG U=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=Julia.Lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.01,153,1684792800"; d="scan'208";a="59686171" Received: from i80.paris.inria.fr (HELO i80.paris.inria.fr.) ([128.93.90.48]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2023 23:15:12 +0200 From: Julia Lawall To: Thierry Reding Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Krishna Reddy , Joerg Roedel , Will Deacon , Robin Murphy , Jonathan Hunter , linux-tegra@vger.kernel.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH 13/26] iommu/tegra: gart: use array_size Date: Fri, 23 Jun 2023 23:14:44 +0200 Message-Id: <20230623211457.102544-14-Julia.Lawall@inria.fr> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230623211457.102544-1-Julia.Lawall@inria.fr> References: <20230623211457.102544-1-Julia.Lawall@inria.fr> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use array_size to protect against multiplication overflows. The changes were done using the following Coccinelle semantic patch: // @@ expression E1, E2; constant C1, C2; identifier alloc = {vmalloc,vzalloc}; @@ ( alloc(C1 * C2,...) | alloc( - (E1) * (E2) + array_size(E1, E2) ,...) ) // Signed-off-by: Julia Lawall --- drivers/iommu/tegra-gart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index a482ff838b53..def222da83f1 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -348,8 +348,8 @@ struct gart_device *tegra_gart_probe(struct device *dev, struct tegra_mc *mc) if (err) goto remove_sysfs; - gart->savedata = vmalloc(resource_size(res) / GART_PAGE_SIZE * - sizeof(u32)); + gart->savedata = vmalloc(array_size(resource_size(res) / GART_PAGE_SIZE, + sizeof(u32))); if (!gart->savedata) { err = -ENOMEM; goto unregister_iommu;