From patchwork Fri Jun 23 21:14:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112314 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6048654vqr; Fri, 23 Jun 2023 14:24:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5CFeQaTXK6S+h8MQDY0twwPdAgUaGovdMeZWVx400zXZdTZc1YaZyB1zLjxsdRXEnzbi3a X-Received: by 2002:a05:6a00:21c2:b0:65a:710a:7855 with SMTP id t2-20020a056a0021c200b0065a710a7855mr17143129pfj.26.1687555479819; Fri, 23 Jun 2023 14:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555479; cv=none; d=google.com; s=arc-20160816; b=itZyw6ACQ4Sj1ZdQ2EQlxvsgx4dxmJdIWcvGWiLrKAS8xBZlbyL7gVnR4REKxeCIl6 tCef1Is6WPwFgP0tozPMgnXj7XKUAS1W9wdKHzwo8h3QIsi2sOIq21PKAnNcMgOk3xil TL6jOPBh/412882D/iW9elAguiJDWmsCRRe+DZE18Wf98Ehyod0nBkf9xluUdFzVVFPO o8/5bbx+aeDIK4oUtGpfDAmjbRtOncTIT0eIxnihsqFhhRCNwUCKztOatneVfgk1dohZ Uw333JTkDKxO0rlk0igx4LA8Ug1kGpNPU+4YVlPZ5c3uw+6Bh8zw9AJvDPT7B5oglMaJ 4iwg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a6567c2000000b0054402b987ecsi244296pgs.803.2023.06.23.14.24.25; Fri, 23 Jun 2023 14:24:39 -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 S231702AbjFWVTA (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769530174806075844?= X-GMAIL-MSGID: =?utf-8?q?1769530174806075844?= 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/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);