Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1616568pxb; Mon, 11 Oct 2021 09:33:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxp33HD4CnRaeathN/gCJuwIhxCT4t4/kcgoSwiFnYbgObjYN85lWmmeVcThY6GY7T1wVeD X-Received: by 2002:a05:6402:40c2:: with SMTP id z2mr44236265edb.41.1633970006396; Mon, 11 Oct 2021 09:33:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633970006; cv=none; d=google.com; s=arc-20160816; b=GZC2O11u1gI1JhhkaH4GtsNgLVfJeChfbywg57GBO3IZkDNjak+b9z0uANv7TzWBFE j/DjlBPaTlP6JZvgqNWc0bFsaVOqzLv/5/I9fLPZLmP3+OgF9psO1vtX4OHqlJ6w2Hlq oag6FjKQr0ICe4LqSk+edjLccoMdBcRx6PFIC9m/3BIhGnqg8YQqMCv5+WOMshd+5g9Z ji2wJHFpax4GhD8DONeqsUvtjZtGbvGtASFaBN8av1H1pE9dUKgFfo2mpi8ioe/oRAd3 Dp+VadnnpdZATyWwX5TqtlGPv6zcpZw4c59M4ITJ/eClPNjJOHDMf/jmnavwuDiGDSCv eDzg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mIlrLoM5h89cCVv2EP4jYFIo1ZcUJNmhts4/ZY9Y/rQ=; b=CIc4T5FrSw5vnYR+k8WfxHsWkRovKfqMj2vtgFUEkVrJ5iZowJWm33OBJaxYCNuFvL Jb5SB0nKSCIimQ6b54j5+w0RcPQOeaPVc0M7HUCfbJ5iNZyyRdUW7BRULn839PLwy1ZP n/ji/IX6ydwAUWSJ86zFnOigYaqTtLrtmnci00Je0C9zaa3q8qFu++TwTAXf7oiFGrJo lSpUR6KFHbI+IHfpDji1WCANd5OgynCg7ZbMcKxyURnaGLtApdFeBnLLt4hChvud3I1W VsXaPRbLYlte2zwJRn/10IB4pumxlB7qp989TZx/PePkE1xS4ggpjkagaI0eI97MREJA PzRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RP2DN7nk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s28si11752753edw.13.2021.10.11.09.33.00; Mon, 11 Oct 2021 09:33:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RP2DN7nk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237959AbhJKN7z (ORCPT + 99 others); Mon, 11 Oct 2021 09:59:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:47528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238050AbhJKN6P (ORCPT ); Mon, 11 Oct 2021 09:58:15 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C99CE61105; Mon, 11 Oct 2021 13:54:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633960479; bh=5j3Deu0c6EsoGoCN0WWehsfjrLouSlTkZlGLA1NTIJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RP2DN7nk2tsJWyj2OxOcH07pZQba9fu3PL++QITOwpaWPFxtTnlLvCISoXEdDlPjn 89q0lbWZqxQlDEwMKcoGPQFXA4b6q4TopvKFrLdQgVSNBTkkkRu9W1bLCuiNuWZ63F OtrByDjlT0oesTankKSR99hraWz2QSmQx2zGxCJY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Shemesh , Tariq Toukan , Saeed Mahameed , Sasha Levin Subject: [PATCH 5.10 39/83] net/mlx5: E-Switch, Fix double allocation of acl flow counter Date: Mon, 11 Oct 2021 15:45:59 +0200 Message-Id: <20211011134509.741545505@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134508.362906295@linuxfoundation.org> References: <20211011134508.362906295@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Moshe Shemesh [ Upstream commit a586775f83bd729ad60b56352dbe067f4bb0beee ] Flow counter is allocated in eswitch legacy acl setting functions without checking if already allocated by previous setting. Add a check to avoid such double allocation. Fixes: 07bab9502641 ("net/mlx5: E-Switch, Refactor eswitch ingress acl codes") Fixes: ea651a86d468 ("net/mlx5: E-Switch, Refactor eswitch egress acl codes") Signed-off-by: Moshe Shemesh Reviewed-by: Tariq Toukan Signed-off-by: Saeed Mahameed Signed-off-by: Sasha Levin --- .../mellanox/mlx5/core/esw/acl/egress_lgcy.c | 12 ++++++++---- .../mellanox/mlx5/core/esw/acl/ingress_lgcy.c | 4 +++- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c index 3e19b1721303..b00c7d47833f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/egress_lgcy.c @@ -79,12 +79,16 @@ int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw, int dest_num = 0; int err = 0; - if (MLX5_CAP_ESW_EGRESS_ACL(esw->dev, flow_counter)) { + if (vport->egress.legacy.drop_counter) { + drop_counter = vport->egress.legacy.drop_counter; + } else if (MLX5_CAP_ESW_EGRESS_ACL(esw->dev, flow_counter)) { drop_counter = mlx5_fc_create(esw->dev, false); - if (IS_ERR(drop_counter)) + if (IS_ERR(drop_counter)) { esw_warn(esw->dev, "vport[%d] configure egress drop rule counter err(%ld)\n", vport->vport, PTR_ERR(drop_counter)); + drop_counter = NULL; + } vport->egress.legacy.drop_counter = drop_counter; } @@ -123,7 +127,7 @@ int esw_acl_egress_lgcy_setup(struct mlx5_eswitch *esw, flow_act.action = MLX5_FLOW_CONTEXT_ACTION_DROP; /* Attach egress drop flow counter */ - if (!IS_ERR_OR_NULL(drop_counter)) { + if (drop_counter) { flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; drop_ctr_dst.type = MLX5_FLOW_DESTINATION_TYPE_COUNTER; drop_ctr_dst.counter_id = mlx5_fc_id(drop_counter); @@ -162,7 +166,7 @@ void esw_acl_egress_lgcy_cleanup(struct mlx5_eswitch *esw, esw_acl_egress_table_destroy(vport); clean_drop_counter: - if (!IS_ERR_OR_NULL(vport->egress.legacy.drop_counter)) { + if (vport->egress.legacy.drop_counter) { mlx5_fc_destroy(esw->dev, vport->egress.legacy.drop_counter); vport->egress.legacy.drop_counter = NULL; } diff --git a/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c b/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c index d64fad2823e7..45570d0a58d2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/esw/acl/ingress_lgcy.c @@ -160,7 +160,9 @@ int esw_acl_ingress_lgcy_setup(struct mlx5_eswitch *esw, esw_acl_ingress_lgcy_rules_destroy(vport); - if (MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) { + if (vport->ingress.legacy.drop_counter) { + counter = vport->ingress.legacy.drop_counter; + } else if (MLX5_CAP_ESW_INGRESS_ACL(esw->dev, flow_counter)) { counter = mlx5_fc_create(esw->dev, false); if (IS_ERR(counter)) { esw_warn(esw->dev, -- 2.33.0