Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13033160rwd; Fri, 23 Jun 2023 14:40:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ73PZa6I4jqF/w7ppuUUY/5pMwP4bJBA/f5OadUZrQzQWljAv1Tn5tR4lTaYQHduAA98hdH X-Received: by 2002:a17:903:2092:b0:1b3:d0f5:70ab with SMTP id d18-20020a170903209200b001b3d0f570abmr251697plc.28.1687556403619; Fri, 23 Jun 2023 14:40:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687556403; cv=none; d=google.com; s=arc-20160816; b=dFKa4AQLaOIYmqC44ZMm59+vmA44qpvlWkmW+tAau8oLDCCGsEpMztPgkKDtg12mmI r8OBveuSgiaIetrBeXShloAia2cL76kd2tmSngPwlYPvKElGD0GcoP16C6rbsZZoW6IV Xn5c+qijswf8m45oNrbwg8IHsRREDYg21eovhdqCxwMxf2Jiu1F4VZgpT/Ab9i7Ctydd Z2tA4PWXUF+q5vfHyO5OGJW4+T4IERMvRoMJSl8Gs/IbevWWzwWA+vcaTMUrCjh0v7FR 1c18UjUzJTIGEnnaIMZgCPKk99QiJVaqXHAKAA0IYv5Gwnb2fSwq/pXmpOKg8E4+FQw4 wtTQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d19-20020a170902b71300b001b66f00d40csi61416pls.351.2023.06.23.14.39.51; Fri, 23 Jun 2023 14:40:03 -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 S232535AbjFWVPm (ORCPT + 99 others); Fri, 23 Jun 2023 17:15:42 -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 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: 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/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;