linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mark Bloch <mbloch@nvidia.com>
To: Jason Gunthorpe <jgg@nvidia.com>, Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.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 23:25:47 +0300	[thread overview]
Message-ID: <ba250d13-337b-04e0-110f-bdeca76e6fd4@nvidia.com> (raw)
In-Reply-To: <20210413200309.GA1350353@nvidia.com>



On 4/13/2021 23:03, Jason Gunthorpe wrote:
> 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()

Will address both comments in the v3. thanks.

Mark
> 
> Jason
> 

      reply	other threads:[~2021-04-13 20:25 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
2021-04-13 20:25   ` Mark Bloch [this message]

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=ba250d13-337b-04e0-110f-bdeca76e6fd4@nvidia.com \
    --to=mbloch@nvidia.com \
    --cc=dledford@redhat.com \
    --cc=jgg@nvidia.com \
    --cc=leon@kernel.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=maorg@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).