From patchwork Fri Jun 23 21:14:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 112307 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6045660vqr; Fri, 23 Jun 2023 14:17:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6qIbhESenfoh0Jzy7jMOS68ufHRK+kDIDQ+aqK+wxZ484O3YB+e/mz+lKAvSSqd9Md/XAC X-Received: by 2002:a05:6a00:2e10:b0:64f:35c8:8584 with SMTP id fc16-20020a056a002e1000b0064f35c88584mr31798054pfb.18.1687555054886; Fri, 23 Jun 2023 14:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555054; cv=none; d=google.com; s=arc-20160816; b=GbyEKvD4DUN94JOAe6RsqJN+JJnOAVHWz7K36GTsF9RL8E00jIzvSwiZ4Z2H90d3xn nyDtSFHgK1Nd0tRVBNRSdkwhES7rUWm7bUalKmVmaXYPGtr8e4o+CnJuWiSuLtgN8Xo8 eLaXlZ9eUdTFhhwsADEiXjWPc/dXj6+HpBpMGj9ASpp1RGcAW/VqjQyLL2fBcI1xUEWl AfSMzYRGSsFzn31C/VrsLPVT9zJgSV+tyZCmUmfkrmX2g3t3wZgtQ9+EykPRQKIT/66p myxDmThzck/J/DhGeXJeqk6bfzL6eatPGlPjHlzgs3r8HL9VJrP+J5bRvDyYASGRlWOV J2mg== 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=/TRxy0AuF5FOCiYvvmf3tnTeoM1gUmxAEjlXeC+Ek4Q=; fh=w9WUcIrhuVsmFPTfZTX+NmB1JSS7q4BCLa9Ptx6Anoo=; b=VC3OTt4WvOGFOlqJX6wsT/Vq6k2WclVBBFaSgE/qnUSUFuY0XYTWdx10sCPWtBgB68 3VtMv/MU4JCpvasGLQm1YcePnWWZrkpvuzqGoX5wiL9HAs5264/AF04W3khCh6W9ttW1 N6Y6BkE9FIvKvIlzHaxR97lKFQHjfGac1lDqlXqdZ08M5DXxUk5eOfXTebDLD1V4/TF9 CMe8SLdseKu+R4gQ1hFMh0cKgcwSKYORGxF0vvnMsIr7uR3gdo42alpg/39IvmqjlIut 8crVfHFMEDmJewr+qLYTHDUOhdfegZvsNoaRqGM6lu01CGoANkvkBei5Vg8467fVVbYr 3scQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=VcpH1Vz0; 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 v9-20020a056a00148900b0066243798ac3si4417pfu.278.2023.06.23.14.17.22; Fri, 23 Jun 2023 14:17:34 -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=VcpH1Vz0; 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 S232724AbjFWVPn (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232596AbjFWVPT (ORCPT ); Fri, 23 Jun 2023 17:15:19 -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 AC44810F1; Fri, 23 Jun 2023 14:15:17 -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=/TRxy0AuF5FOCiYvvmf3tnTeoM1gUmxAEjlXeC+Ek4Q=; b=VcpH1Vz0lqQVGPsxzochEoOjLBSc7ukpvC0FInUkitVeye74rVXmkSmp 1zR87l1hIw+Bcv7BD6j6LRDjNKx1pb8Z8uiDSlyxpiroLgRzEW8mz11z+ x0vo0RpBsnP8Y82mxqlPr9vofLYNF8zqIvipC0saNwk8j8BrYh7KafGGo o=; 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="59686169" 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:12 +0200 From: Julia Lawall To: Shannon Nelson Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Brett Creeley , drivers@pensando.io, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/26] ionic: use array_size Date: Fri, 23 Jun 2023 23:14:42 +0200 Message-Id: <20230623211457.102544-12-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?1769529729049890136?= X-GMAIL-MSGID: =?utf-8?q?1769529729049890136?= 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 Acked-by: Shannon Nelson --- drivers/net/ethernet/pensando/ionic/ionic_lif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c index 957027e546b3..f2e2c6853536 100644 --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c @@ -560,7 +560,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, new->q.dev = dev; new->flags = flags; - new->q.info = vzalloc(num_descs * sizeof(*new->q.info)); + new->q.info = vzalloc(array_size(num_descs, sizeof(*new->q.info))); if (!new->q.info) { netdev_err(lif->netdev, "Cannot allocate queue info\n"); err = -ENOMEM; @@ -581,7 +581,7 @@ static int ionic_qcq_alloc(struct ionic_lif *lif, unsigned int type, if (err) goto err_out; - new->cq.info = vzalloc(num_descs * sizeof(*new->cq.info)); + new->cq.info = vzalloc(array_size(num_descs, sizeof(*new->cq.info))); if (!new->cq.info) { netdev_err(lif->netdev, "Cannot allocate completion queue info\n"); err = -ENOMEM;