netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Saeed Mahameed <saeed@kernel.org>
Cc: "David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Eric Dumazet <edumazet@google.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	netdev@vger.kernel.org, Tariq Toukan <tariqt@nvidia.com>,
	Gal Pressman <gal@nvidia.com>,
	Leon Romanovsky <leonro@nvidia.com>,
	Yevgeny Kliteynik <kliteyn@nvidia.com>,
	Itamar Gozlan <igozlan@nvidia.com>
Subject: Re: [net-next V3 11/15] net/mlx5: HWS, added memory management handling
Date: Sat, 7 Sep 2024 15:28:06 +0100	[thread overview]
Message-ID: <20240907142806.GS2097826@kernel.org> (raw)
In-Reply-To: <20240906215411.18770-12-saeed@kernel.org>

On Fri, Sep 06, 2024 at 02:54:06PM -0700, Saeed Mahameed wrote:
> From: Yevgeny Kliteynik <kliteyn@nvidia.com>
> 
> Added object pools and buddy allocator functionality.
> 
> Reviewed-by: Itamar Gozlan <igozlan@nvidia.com>
> Signed-off-by: Yevgeny Kliteynik <kliteyn@nvidia.com>
> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>

...

> +static struct mlx5hws_pool_resource *
> +hws_pool_create_one_resource(struct mlx5hws_pool *pool, u32 log_range,
> +			     u32 fw_ft_type)
> +{
> +	struct mlx5hws_cmd_ste_create_attr ste_attr;
> +	struct mlx5hws_cmd_stc_create_attr stc_attr;
> +	struct mlx5hws_pool_resource *resource;
> +	u32 obj_id;
> +	int ret;
> +
> +	resource = kzalloc(sizeof(*resource), GFP_KERNEL);
> +	if (!resource)
> +		return NULL;
> +
> +	switch (pool->type) {
> +	case MLX5HWS_POOL_TYPE_STE:
> +		ste_attr.log_obj_range = log_range;
> +		ste_attr.table_type = fw_ft_type;
> +		ret = mlx5hws_cmd_ste_create(pool->ctx->mdev, &ste_attr, &obj_id);
> +		break;
> +	case MLX5HWS_POOL_TYPE_STC:
> +		stc_attr.log_obj_range = log_range;
> +		stc_attr.table_type = fw_ft_type;
> +		ret = mlx5hws_cmd_stc_create(pool->ctx->mdev, &stc_attr, &obj_id);
> +		break;
> +	default:
> +		return NULL;

Sorry, but this now appears to leak resource. Maybe:

		goto free_resource;

Or:

		ret = -EINVAL;

> +	}
> +
> +	if (ret) {
> +		mlx5hws_err(pool->ctx, "Failed to allocate resource objects\n");
> +		goto free_resource;
> +	}
> +
> +	resource->pool = pool;
> +	resource->range = 1 << log_range;
> +	resource->base_id = obj_id;
> +
> +	return resource;
> +
> +free_resource:
> +	kfree(resource);
> +	return NULL;
> +}

...

-- 
pw-bot: cr

  reply	other threads:[~2024-09-07 14:28 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-06 21:53 [pull request][net-next V3 00/15] mlx5 updates 2024-09-02 Saeed Mahameed
2024-09-06 21:53 ` [net-next V3 01/15] net/mlx5: Added missing mlx5_ifc definition for HW Steering Saeed Mahameed
2024-09-06 21:53 ` [net-next V3 02/15] net/mlx5: Added missing definitions in preparation " Saeed Mahameed
2024-09-06 21:53 ` [net-next V3 03/15] net/mlx5: HWS, added actions handling Saeed Mahameed
2024-09-06 21:53 ` [net-next V3 04/15] net/mlx5: HWS, added tables handling Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 05/15] net/mlx5: HWS, added rules handling Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 06/15] net/mlx5: HWS, added definers handling Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 07/15] net/mlx5: HWS, added matchers functionality Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 08/15] net/mlx5: HWS, added FW commands handling Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 09/15] net/mlx5: HWS, added modify header pattern and args handling Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 10/15] net/mlx5: HWS, added vport handling Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 11/15] net/mlx5: HWS, added memory management handling Saeed Mahameed
2024-09-07 14:28   ` Simon Horman [this message]
2024-09-07 20:32     ` Yevgeny Kliteynik
2024-09-06 21:54 ` [net-next V3 12/15] net/mlx5: HWS, added backward-compatible API handling Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 13/15] net/mlx5: HWS, added debug dump and internal headers Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 14/15] net/mlx5: HWS, added send engine and context handling Saeed Mahameed
2024-09-06 21:54 ` [net-next V3 15/15] net/mlx5: HWS, added API and enabled HWS support Saeed Mahameed

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=20240907142806.GS2097826@kernel.org \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=igozlan@nvidia.com \
    --cc=kliteyn@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leonro@nvidia.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=saeed@kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@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).