Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13031286rwd; Fri, 23 Jun 2023 14:37:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4EIATHXUupXGncV1jOj1SWv80WWMIg4EqJRdrBxA/e6i2lrieVAWOZL5ytcbQT+mS+1U5U X-Received: by 2002:a17:90a:ea0a:b0:24d:ef23:fe28 with SMTP id w10-20020a17090aea0a00b0024def23fe28mr13063061pjy.49.1687556266201; Fri, 23 Jun 2023 14:37:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556266; cv=none; d=google.com; s=arc-20160816; b=D+h5SBzkvcFbQm1m/waHoK27NOcQOe4rYWM+cZKTA4u49VxsffqGFIlAJ1oYOgIjMT Le28Al8S/JdcXeFqDent47fwQsWNOIef79hdl5EW6JKDO6L8PzQG/AWuVHLQSEOPA2SK xKyaZPmB6ZzbhRfKqLPOAcxMKiLtOmXGgFYPerTnnLNeZ1JRtuE08cA0KN0he3Yno6/1 2A8htcGswINLckn6ZqSpk244/4E4bcuq3nunrZZs9PX/mi5pZO+56Ke94BDY6ApMbAs8 U2UGlGvmeoiDMd5hQL9LqsdXJGWcIoqjXPc1P5skZpA80RWXiNOWa10JbFiLMIpajrG0 9L1A== 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=6uQt9cKBk2Sag9c2YWWjAaGPZs3k3Hvob+itlodbJvE=; fh=Cqc/z/U6Zn38c+j1JjCoDjkQ1/zqQ8NO+by02VHnZBE=; b=GmwLqfNg0DqOPEJS2vek92zjbu5LrmYp3LK7d2LV9z0y87xVaLW0/7cTz6A5inVMKv 2GR+EqsGvu+cRVO1cxlADFXG52PzeMDb/1ptGGnrsoFMhcG1rQT2tH68XkvwCE+cSxzQ r1zlliecun27hoq0y0N2q/dfQDb7Pbpto+Ahx1cdYwG0tnWmDkbd2lPFV4BA71x+1u9r 0m3ZvVe0yIKjMPaUlMMxTO4mvBy/3dGrd6Njxp18xEHCWsGoivKuxXl3ibTEGItMSxfH PbYsltteXmmINb0aWGxB/zshTocaLgoSObP5etBc0j+nu5ydqmJzORFOGnlIIYRwpI94 DOQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=uUeK7v84; 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 v6-20020a17090ac90600b002536c5eb7cfsi2611108pjt.58.2023.06.23.14.37.34; Fri, 23 Jun 2023 14:37:46 -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=uUeK7v84; 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 S232503AbjFWVTA (ORCPT + 99 others); Fri, 23 Jun 2023 17:19:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229673AbjFWVSb (ORCPT ); Fri, 23 Jun 2023 17:18:31 -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 D82ED294E; Fri, 23 Jun 2023 14:17:47 -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=6uQt9cKBk2Sag9c2YWWjAaGPZs3k3Hvob+itlodbJvE=; b=uUeK7v84Q78fePqXn2J06hqIJHU44vOesDD7hu1wYYvYAjqJ0J/cmLDe UQgoZjPb5/RNMRv/6e8PHGv3hzro41BQHfbx/RndVD2XB7GRo04sYh6fK tpHpLxNHWHvUskJqhO23GItuTkGYflimreyRkgYm+KNieGnnWye4tIA+W c=; 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="59686160" 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:10 +0200 From: Julia Lawall To: Veerasenareddy Burru Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Abhijit Ayarekar , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/26] octeon_ep: use array_size Date: Fri, 23 Jun 2023 23:14:33 +0200 Message-Id: <20230623211457.102544-3-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=unavailable 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/net/ethernet/marvell/octeon_ep/octep_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c index 392d9b0da0d7..185b7e50ee77 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_rx.c @@ -158,7 +158,7 @@ static int octep_setup_oq(struct octep_device *oct, int q_no) goto desc_dma_alloc_err; } - oq->buff_info = vzalloc(oq->max_count * OCTEP_OQ_RECVBUF_SIZE); + oq->buff_info = vzalloc(array_size(oq->max_count, OCTEP_OQ_RECVBUF_SIZE)); if (unlikely(!oq->buff_info)) { dev_err(&oct->pdev->dev, "Failed to allocate buffer info for OQ-%d\n", q_no);