Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13029912rwd; Fri, 23 Jun 2023 14:36:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6J3FfiuSVaCkPkZdkdV1lXb5QmuwnTQLyvW5w8fD9wwx/R1x74W+kRewGZcXsYa74Ie4VD X-Received: by 2002:a05:6808:20f:b0:3a0:5596:efe8 with SMTP id l15-20020a056808020f00b003a05596efe8mr7237760oie.54.1687556164179; Fri, 23 Jun 2023 14:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556164; cv=none; d=google.com; s=arc-20160816; b=X/0ygJhrcEyeh57ke1KqqwcmKK343LlG8KJkmXNtCV1Chm4C2r+e9lEUvUKQkHPkeg PzFfuj6SUETHhkp2lYY98wzzpVyUQAZEN6O4wrop8fKr/rN4/O3Gr+JJ2VTQ1tSz13ff 01vYJxfejD/QeonEN4xEzz8JjF0Q3W7/Bkd34urhXVf+LuyRPhr19NcdkaPJ7kKudBui yqkfanbVqm26+DmvVK1cWB25xJ/J+NXpWwFniCDdMG1ON4gQw9X/rI2BI1LYbJtrLomY lnrBA1qplDvV8uCTVpRotv1rQn0Lp2AJm+krh0vJSd5bbwijSLMr/VSIKkNOx7QfGF0s yZXg== 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=8RgN37sI7dQZ+yBNJgvV+FVERbz2KA6A4JGbVoPo1D8=; fh=4GhRN2p8jF6l7uhi+UJ/CswsbaxAF4Vi9m+VjlL/GZw=; b=kmjJBHmxDXF2E1+bZWPnG+ud2zvpF7FIoMwodztSfSp+qfo77QpQPnEbpttuwGWue4 i4+iTx4QclzziLkPlaxbCSLOTihk872APkKgPyUBfvYN3/WJkntzgNXLpyCUabfuvTXo ULVLNEHXY7QsPIdJh7cPlTReTVvIllV4wua4BpT4ACinDXYksi/lnzE8W1AyMD4+WaMz 55tOP2gAbtcJKRHdNiFv7zfSNjZPRxkyRcFU/tzIc/Dj2MkVuFYr2sMkYyRbRSDsVNz/ hpvOXnmOoLgvfIFOqeuC086nFKJK35wYvGDCnMtaLYTmU9FXJ2sZOwSkO9NtQvsyUHcT athQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=ZLSOgmbf; 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 p11-20020a17090adf8b00b002612ed47e41si333821pjv.117.2023.06.23.14.35.51; Fri, 23 Jun 2023 14:36:04 -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=ZLSOgmbf; 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 S232124AbjFWVQT (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50356 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232866AbjFWVPd (ORCPT ); Fri, 23 Jun 2023 17:15:33 -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 A1F8626BD; Fri, 23 Jun 2023 14:15:21 -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=8RgN37sI7dQZ+yBNJgvV+FVERbz2KA6A4JGbVoPo1D8=; b=ZLSOgmbfYoFK1LfswZnkAko5w1qaeuRTBPVtfsuJhYufYAShfc08lrY5 GfmwSRRDmk+b4IYZGmpWxgs4LgkYSVKQuaZq7LE+mHoJVN5ZQicrxpb1d qwR/n8FqYT1ATKyZe3Ay1Bz27c81Fou59W2Zj2TESMWOmR77CEA5urk0P s=; 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="59686177" 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:13 +0200 From: Julia Lawall To: Selvin Xavier Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Jason Gunthorpe , Leon Romanovsky , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/26] RDMA/bnxt_re: use array_size Date: Fri, 23 Jun 2023 23:14:50 +0200 Message-Id: <20230623211457.102544-20-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/infiniband/hw/bnxt_re/qplib_res.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/bnxt_re/qplib_res.c b/drivers/infiniband/hw/bnxt_re/qplib_res.c index 81b0c5e879f9..f049b627e734 100644 --- a/drivers/infiniband/hw/bnxt_re/qplib_res.c +++ b/drivers/infiniband/hw/bnxt_re/qplib_res.c @@ -118,11 +118,11 @@ static int __alloc_pbl(struct bnxt_qplib_res *res, else pages = sginfo->npages; /* page ptr arrays */ - pbl->pg_arr = vmalloc(pages * sizeof(void *)); + pbl->pg_arr = vmalloc(array_size(pages, sizeof(void *))); if (!pbl->pg_arr) return -ENOMEM; - pbl->pg_map_arr = vmalloc(pages * sizeof(dma_addr_t)); + pbl->pg_map_arr = vmalloc(array_size(pages, sizeof(dma_addr_t))); if (!pbl->pg_map_arr) { vfree(pbl->pg_arr); pbl->pg_arr = NULL;