netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yevgeny Kliteynik <kliteyn@nvidia.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Cosmin Ratiu <cratiu@nvidia.com>, Mark Bloch <mbloch@nvidia.com>,
	Vlad Dogaru <vdogaru@nvidia.com>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH v2 net] net/mlx5: HWS, Add error checking to hws_bwc_rule_complex_hash_node_get()
Date: Thu, 12 Jun 2025 01:10:12 +0300	[thread overview]
Message-ID: <1070a074-d1ab-461b-b003-d91bfe024df3@nvidia.com> (raw)
In-Reply-To: <aEmBONjyiF6z5yCV@stanley.mountain>

On 11-Jun-25 16:14, Dan Carpenter wrote:
> Check for if ida_alloc() or rhashtable_lookup_get_insert_fast() fails.
> 
> Fixes: 17e0accac577 ("net/mlx5: HWS, support complex matchers")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> v2: Add error checking for ida_alloc() and add cleanup.
> 
>   .../mlx5/core/steering/hws/bwc_complex.c      | 19 +++++++++++++++++--
>   1 file changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc_complex.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc_complex.c
> index 70768953a4f6..ca7501c57468 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc_complex.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/hws/bwc_complex.c
> @@ -1070,7 +1070,7 @@ hws_bwc_rule_complex_hash_node_get(struct mlx5hws_bwc_rule *bwc_rule,
>   	struct mlx5hws_bwc_matcher *bwc_matcher = bwc_rule->bwc_matcher;
>   	struct mlx5hws_bwc_complex_rule_hash_node *node, *old_node;
>   	struct rhashtable *refcount_hash;
> -	int i;
> +	int ret, i;
>   
>   	bwc_rule->complex_hash_node = NULL;
>   
> @@ -1078,7 +1078,11 @@ hws_bwc_rule_complex_hash_node_get(struct mlx5hws_bwc_rule *bwc_rule,
>   	if (unlikely(!node))
>   		return -ENOMEM;
>   
> -	node->tag = ida_alloc(&bwc_matcher->complex->metadata_ida, GFP_KERNEL);
> +	ret = ida_alloc(&bwc_matcher->complex->metadata_ida, GFP_KERNEL);
> +	if (ret < 0)
> +		goto err_free_node;
> +	node->tag = ret;
> +
>   	refcount_set(&node->refcount, 1);
>   
>   	/* Clear match buffer - turn off all the unrelated fields
> @@ -1094,6 +1098,11 @@ hws_bwc_rule_complex_hash_node_get(struct mlx5hws_bwc_rule *bwc_rule,
>   	old_node = rhashtable_lookup_get_insert_fast(refcount_hash,
>   						     &node->hash_node,
>   						     hws_refcount_hash);
> +	if (IS_ERR(old_node)) {
> +		ret = PTR_ERR(old_node);
> +		goto err_free_ida;
> +	}
> +
>   	if (old_node) {
>   		/* Rule with the same tag already exists - update refcount */
>   		refcount_inc(&old_node->refcount);
> @@ -1112,6 +1121,12 @@ hws_bwc_rule_complex_hash_node_get(struct mlx5hws_bwc_rule *bwc_rule,
>   
>   	bwc_rule->complex_hash_node = node;
>   	return 0;
> +
> +err_free_ida:
> +	ida_free(&bwc_matcher->complex->metadata_ida, node->tag);
> +err_free_node:
> +	kfree(node);
> +	return ret;
>   }
>   
>   static void

Reviewed-by: Yevgeny Kliteynik <kliteyn@nvidia.com>

Thanks Dan


  reply	other threads:[~2025-06-11 22:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 13:14 [PATCH v2 net] net/mlx5: HWS, Add error checking to hws_bwc_rule_complex_hash_node_get() Dan Carpenter
2025-06-11 22:10 ` Yevgeny Kliteynik [this message]
2025-06-12 15:20 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1070a074-d1ab-461b-b003-d91bfe024df3@nvidia.com \
    --to=kliteyn@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=cratiu@nvidia.com \
    --cc=dan.carpenter@linaro.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    --cc=vdogaru@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).