Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13023046rwd; Fri, 23 Jun 2023 14:28:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5flCAWTQRY10+D+oIPe3DBloRJJ3Q7vW0wQsCO7PTmvwD5gbYCelAvIvFl5Uh3Rg+1aiOy X-Received: by 2002:a05:6a00:2345:b0:665:7f27:dbab with SMTP id j5-20020a056a00234500b006657f27dbabmr14568363pfj.25.1687555731721; Fri, 23 Jun 2023 14:28:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687555731; cv=none; d=google.com; s=arc-20160816; b=d1BjoN+6ACliXRhSbxXSDv4jdWfz8SS8+Ihb0DR+RMZW3X9GkBF7pWHgWshk/jkdiN Bcx5W0e0J4fFz1JPhtXilcJvlgT8h7u0r81Q93a5oczsa+nyl7A/mKwz02VrOX7EDgAX +PS+uklSt3NlYFPkatamXkbkCygxWvmSmxTFIAPGYKTQmTplqgNi+8jzod2TC6mDRY8V 8ojbP9dOXIJZxcVckVELXmb0I5r3Ep+vsrpEkXovBkgdXOUvaO86mRz5lmV+Ih8tJFYN uqsZsklv6VsksfUWKJN476Fgj5y5z0XIwxKoadjx1k49OqyJAniD/SOBC+Pot03xzvAj lcMw== 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=GCWo4PVrP3ZeFd8PIff442f3VLqG/AMKNMFkIT9T6cA=; fh=kAwTNgFKZnElgUbacnbPeNcvgCOdjAyuqnkcwpNxIGk=; b=CCmIjglvNV9d6DyFDUXfpBy7ppb9GiFdbbZD6y9rB3wjyV7CttraXhQk2E4N9IM0li yaN2RxJL8Hrn6Xa4PLa5fGOC5i7pyggbkTLUhhrPxvaMoVvCJHp9Qr1G05ggf4mSMEm9 lijwZwzMVtyIBT8DvdRkNwwVAnwhSEZM/eWZNoiCfxAk+pGG7JnVrXREGXEHBha9YQdm yjkAfZAj/iLAO6HUrDETxZDfxuzproV2/YXz+ZzG+9RZRKd8YIe6zUAZ47kTWqC03B4n rkg6wp40qblaHci+SAt1M3b8l3LjUtyZ8rkogL9OTIxwhf0lPTozvyh4AiLMgQfykXcr G3gg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=K02CyeC0; 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 d8-20020a056a0024c800b0065930ad0643si61464pfv.79.2023.06.23.14.28.39; Fri, 23 Jun 2023 14:28:51 -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=K02CyeC0; 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 S232660AbjFWVU6 (ORCPT + 99 others); Fri, 23 Jun 2023 17:20:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232609AbjFWVUi (ORCPT ); Fri, 23 Jun 2023 17:20:38 -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 30BAC2D46; Fri, 23 Jun 2023 14:19:22 -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=GCWo4PVrP3ZeFd8PIff442f3VLqG/AMKNMFkIT9T6cA=; b=K02CyeC0TxO7IAr7a3O+52eMgvms+F1/AvW0vYiFyEyImYoyQe3rBgJa TpAOj/W+1u1Yyv5zigBnWDQbMKc4dofND330WeFJkbKNYeeW9PRFvUD6F JG+WW/GS1N7xtJpu/yozutxXj7AYxLY+aNccGkg1oAWTQTtopCJ72nAgU E=; 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="59686167" 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:11 +0200 From: Julia Lawall To: Shannon Nelson Cc: keescook@chromium.org, kernel-janitors@vger.kernel.org, Brett Creeley , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/26] pds_core: use array_size Date: Fri, 23 Jun 2023 23:14:40 +0200 Message-Id: <20230623211457.102544-10-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/amd/pds_core/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/amd/pds_core/core.c b/drivers/net/ethernet/amd/pds_core/core.c index 483a070d96fa..d87f45a1ee2f 100644 --- a/drivers/net/ethernet/amd/pds_core/core.c +++ b/drivers/net/ethernet/amd/pds_core/core.c @@ -196,7 +196,7 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type, unsigned int index, dma_addr_t q_base_pa; int err; - qcq->q.info = vzalloc(num_descs * sizeof(*qcq->q.info)); + qcq->q.info = vzalloc(array_size(num_descs, sizeof(*qcq->q.info))); if (!qcq->q.info) { err = -ENOMEM; goto err_out; @@ -219,7 +219,7 @@ int pdsc_qcq_alloc(struct pdsc *pdsc, unsigned int type, unsigned int index, if (err) goto err_out_free_q_info; - qcq->cq.info = vzalloc(num_descs * sizeof(*qcq->cq.info)); + qcq->cq.info = vzalloc(array_size(num_descs, sizeof(*qcq->cq.info))); if (!qcq->cq.info) { err = -ENOMEM; goto err_out_free_irq;