Message ID | 20230623211457.102544-20-Julia.Lawall@inria.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6053730vqr; Fri, 23 Jun 2023 14:37:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40eqCTzqIjx03IuANeFxce0tunJ81yk5ivTd2mgXlRWV/q8Xpv2wIkY/tdS/pDKkpZFH0G X-Received: by 2002:a05:6a00:99c:b0:668:6c2a:c4e3 with SMTP id u28-20020a056a00099c00b006686c2ac4e3mr16689476pfg.13.1687556269134; Fri, 23 Jun 2023 14:37:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556269; cv=none; d=google.com; s=arc-20160816; b=TXBABmY+SKURTJKtSIgnx41cxE9MjqMIKWC+UzfDIVlT6EPSKJN056PtABjmxvR7IL OZX24HCQI4xNogZ/4aK5DCUtlwHPY4tAsADI+nW6Adu6RPUhDCgHPTWa9nSOHycVLXE6 wJDIVyGNuuynus4Z91JplXOL0Rxo9BelA8KT4KZz/y5bcd03phPT/GKQ5ZII5GV0F/Fk iEaUy9PMKEs7ihhHxsbqcLzbwcr0GegN2lxGwwZsXqp/VvxQZ+ovrqdQ/xjKjvM+ALLN tsAg+1SCkKMHvBfKLXSJcQPlkl82rObitkugjcWJx6VcJf3WuZBiUiZ8bNC3ioFtgwXS 7nSw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y31-20020a056a00181f00b0066885c2a4besi69691pfa.65.2023.06.23.14.37.35; Fri, 23 Jun 2023 14:37:49 -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 S231947AbjFWVQU (ORCPT <rfc822;maxin.john@gmail.com> + 99 others); Fri, 23 Jun 2023 17:16:20 -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 <rfc822;linux-kernel@vger.kernel.org>); 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 <Julia.Lawall@inria.fr> To: Selvin Xavier <selvin.xavier@broadcom.com> Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>, 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769531002426541880?= X-GMAIL-MSGID: =?utf-8?q?1769531002426541880?= |
Series |
use array_size
|
|
Commit Message
Julia Lawall
June 23, 2023, 9:14 p.m. UTC
Use array_size to protect against multiplication overflows.
The changes were done using the following Coccinelle semantic patch:
// <smpl>
@@
expression E1, E2;
constant C1, C2;
identifier alloc = {vmalloc,vzalloc};
@@
(
alloc(C1 * C2,...)
|
alloc(
- (E1) * (E2)
+ array_size(E1, E2)
,...)
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
---
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;