Message ID | 20230623211457.102544-12-Julia.Lawall@inria.fr |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> 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 <rfc822;maxin.john@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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 <Julia.Lawall@inria.fr> To: Shannon Nelson <shannon.nelson@amd.com> Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Brett Creeley <brett.creeley@amd.com>, drivers@pensando.io, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, 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: <linux-kernel.vger.kernel.org> 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?= |
Series |
use array_size
|
|
Commit Message
Julia Lawall
June 23, 2023, 9:14 p.m. UTC
Use array_size to protect against multiplication overflows.
The changes were done using the following Coccinelle semantic patch:
// <smpl>
@@
expression E1, E2;
constant C1, C2;
identifier alloc = {vmalloc,vzalloc};
@@
(
alloc(C1 * C2,...)
|
alloc(
- (E1) * (E2)
+ array_size(E1, E2)
,...)
)
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
---
drivers/net/ethernet/pensando/ionic/ionic_lif.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On Fri, Jun 23, 2023 at 11:14:42PM +0200, Julia Lawall wrote: > Use array_size to protect against multiplication overflows. > > The changes were done using the following Coccinelle semantic patch: > > // <smpl> > @@ > expression E1, E2; > constant C1, C2; > identifier alloc = {vmalloc,vzalloc}; > @@ > > ( > alloc(C1 * C2,...) > | > alloc( > - (E1) * (E2) > + array_size(E1, E2) > ,...) > ) > // </smpl> > > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Reviewed-by: Simon Horman <simon.horman@corigine.com>
On 6/23/23 2:14 PM, Julia Lawall wrote: > > Use array_size to protect against multiplication overflows. > > The changes were done using the following Coccinelle semantic patch: > > // <smpl> > @@ > expression E1, E2; > constant C1, C2; > identifier alloc = {vmalloc,vzalloc}; > @@ > > ( > alloc(C1 * C2,...) > | > alloc( > - (E1) * (E2) > + array_size(E1, E2) > ,...) > ) > // </smpl> > > Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Thanks, Acked-by: Shannon Nelson <shannon.nelson@amd.com> > > --- > 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; > > -- > You received this message because you are subscribed to the Google Groups "Pensando Drivers" group. > To unsubscribe from this group and stop receiving emails from it, send an email to drivers+unsubscribe@pensando.io. > To view this discussion on the web visit https://groups.google.com/a/pensando.io/d/msgid/drivers/20230623211457.102544-12-Julia.Lawall%40inria.fr.
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;