From patchwork Fri Jun 23 21:14:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112312 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6046516vqr; Fri, 23 Jun 2023 14:19:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7BfsJh3sesVAgVMLFeWkU2BoOmP2gui05orKJH0fTEKppv+bloCKOZg88k1DRIyAfE6HBD X-Received: by 2002:a17:902:da84:b0:1b6:78a1:93c7 with SMTP id j4-20020a170902da8400b001b678a193c7mr286773plx.39.1687555180921; Fri, 23 Jun 2023 14:19:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555180; cv=none; d=google.com; s=arc-20160816; b=l+7/C+kRjWNik7rfqPktxPIEU2JtuTwz1FCOHzlOSU+9xo2M/2+k574DUVgld4EKME KM3/JP2wYdBkWPVBiv4p6NJ1iBgeaFV0dUCh/MzMDQP9QFeoziREWScGtlcgDAcgQLy9 l7zFSuksulcioiMsIVUwrAsmOo1OcWzUFdWTDmuXQ+UnwL8Lx6q270+A0c/TgtaqmDCA pl9yESi+tc//xWtVF0zDAtRFaCoYWvwZvJwkG9TH4CbhzGRf0QbTDJ4SsU8mGBhO2kZD 9OtMzan6PPBsyl6XxLNXlttqupvjVlvNsuPSqcKMP8Ya4xasd0yHJrmv0MTr8wzvepqL fRaQ== 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=6pln8KBe2ITtf0Rjafl/GtS76k6Cn8LbOnTYdoKfe3I=; fh=m3wHYztPG1Z7IXi0XlhdTZNDnFaSzXWtQpM9ZHCRd/0=; b=S7SopIaSsKxBJSscm9Y7OWmP9i4ZdDAniqqyYfcTL6Jv+6i3fRF1ql/sb8AwM/XAwx PcziAeCAyFtEOcT54hAk9UXPC3fENFIg929z7x9pgGlDBi8OYHUhXmtocqC2HDLeWK4r RNC9HaHVvw4mfFznQBSS0GpkoHDlctB5UylujRdbgzKJIrf7ryBclos+b/FzPTcxL4vA kxAivNJo3pkTdv0Drf2X7OxM9yy9sN/fWYXNW0G8rYBtb1w67TN8GdtsFvT90kZHv/d+ 2sDmJnS5bn3tx7bnKxpQ3u9WDlw+lPm5ocmqXY06sqrInUArTJ1wUgZgCVaKoctqVRZ5 ZMaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=pKNmqBiy; 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 bf11-20020a170902b90b00b001a68f933777si50629plb.245.2023.06.23.14.19.28; Fri, 23 Jun 2023 14:19:40 -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=pKNmqBiy; 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 S232944AbjFWVQa (ORCPT + 99 others); Fri, 23 Jun 2023 17:16:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232884AbjFWVP5 (ORCPT ); Fri, 23 Jun 2023 17:15:57 -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 3D93C2944; Fri, 23 Jun 2023 14:15:25 -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=6pln8KBe2ITtf0Rjafl/GtS76k6Cn8LbOnTYdoKfe3I=; b=pKNmqBiygwlNLCzGuSQt/yjs2FsRFeqJtZEf1QiTQmJSp4Fke68U0eM6 MjqGe7c1XWHvQYZR8PMOxPokjRn3KFG8EMkHO6Z9TDu+gTL1yvuoFUJVx XTtGe+P9TO7DPba/l6tlQHgJsnQdFj/RZ2EOMJ4okLFBWw40Mu0eNC8LI 8=; 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="59686180" 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:14 +0200 From: Julia Lawall To: "K. Y. Srinivasan" Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Haiyang Zhang , Wei Liu , Dexuan Cui , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 22/26] net: mana: use array_size Date: Fri, 23 Jun 2023 23:14:53 +0200 Message-Id: <20230623211457.102544-23-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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769529861444629323?= X-GMAIL-MSGID: =?utf-8?q?1769529861444629323?= 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 Reviewed-by: Simon Horman --- drivers/net/ethernet/microsoft/mana/hw_channel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microsoft/mana/hw_channel.c b/drivers/net/ethernet/microsoft/mana/hw_channel.c index 9d1507eba5b9..e82c513760f9 100644 --- a/drivers/net/ethernet/microsoft/mana/hw_channel.c +++ b/drivers/net/ethernet/microsoft/mana/hw_channel.c @@ -627,7 +627,7 @@ static int mana_hwc_establish_channel(struct gdma_context *gc, u16 *q_depth, if (WARN_ON(cq->id >= gc->max_num_cqs)) return -EPROTO; - gc->cq_table = vzalloc(gc->max_num_cqs * sizeof(struct gdma_queue *)); + gc->cq_table = vzalloc(array_size(gc->max_num_cqs, sizeof(struct gdma_queue *))); if (!gc->cq_table) return -ENOMEM;