All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>,
	Mark Bloch <mbloch@nvidia.com>,
	linux-api@vger.kernel.org, linux-rdma@vger.kernel.org,
	Maor Gottlieb <maorg@nvidia.com>
Subject: Re: [PATCH rdma-next v2] RDMA/mlx5: Expose private query port
Date: Tue, 13 Apr 2021 17:03:09 -0300	[thread overview]
Message-ID: <20210413200309.GA1350353@nvidia.com> (raw)
In-Reply-To: <20210401085004.577338-1-leon@kernel.org>

On Thu, Apr 01, 2021 at 11:50:04AM +0300, Leon Romanovsky wrote:

> +static int UVERBS_HANDLER(MLX5_IB_METHOD_QUERY_PORT)(
> +	struct uverbs_attr_bundle *attrs)
> +{
> +	struct mlx5_ib_uapi_query_port *info;
> +	struct mlx5_ib_ucontext *c;
> +	struct mlx5_ib_dev *dev;
> +	u32 port_num;
> +	int ret;
> +
> +	if (uverbs_copy_from(&port_num, attrs,
> +			     MLX5_IB_ATTR_QUERY_PORT_PORT_NUM))
> +		return -EFAULT;
> +
> +	c = to_mucontext(ib_uverbs_get_ucontext(attrs));
> +	if (IS_ERR(c))
> +		return PTR_ERR(c);
> +	dev = to_mdev(c->ibucontext.device);
> +
> +	if (!rdma_is_port_valid(&dev->ib_dev, port_num))
> +		return -EINVAL;
> +
> +	info = uverbs_zalloc(attrs, sizeof(*info));
> +	if (IS_ERR(info))
> +		return PTR_ERR(info);

This allocation is not needed, info is small enough to be on the stack

> +
> +	if (mlx5_eswitch_mode(dev->mdev) == MLX5_ESWITCH_OFFLOADS) {
> +		ret = fill_switchdev_info(dev, port_num, info);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return uverbs_copy_to(attrs, MLX5_IB_ATTR_QUERY_PORT, info,
> +			      sizeof(*info));

This should be 

uverbs_copy_to_struct_or_zero()

Jason

  parent reply	other threads:[~2021-04-13 20:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01  8:50 [PATCH rdma-next v2] RDMA/mlx5: Expose private query port Leon Romanovsky
2021-04-08 18:54 ` Jason Gunthorpe
2021-04-11 11:43   ` Leon Romanovsky
2021-04-11 12:33     ` Yishai Hadas
2021-04-13 20:03 ` Jason Gunthorpe [this message]
2021-04-13 20:25   ` Mark Bloch

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=20210413200309.GA1350353@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=dledford@redhat.com \
    --cc=leon@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maorg@nvidia.com \
    --cc=mbloch@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.