Re: [rdma-next 20/22] IB/mlx4: Check that reserved fields in mlx4_ib_create_qp_rss are zero

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 11, 2017 at 01:50:01PM +0300, Leon Romanovsky wrote:
> From: Guy Levi <guyle@xxxxxxxxxxxx>
> 
> According to mlx4 convention, need to fail the command due to a non-zero
> value in the user data which is expected to be zero.
> 
> Fixes: 3078f5f1bd8b ("IB/mlx4: Add support for RSS QP")
> Signed-off-by: Guy Levi <guyle@xxxxxxxxxxxx>
> Signed-off-by: Leon Romanovsky <leon@xxxxxxxxxx>
> ---
>  drivers/infiniband/hw/mlx4/qp.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
> index 44d2d0a2d5e0..e992251b4ef1 100644
> --- a/drivers/infiniband/hw/mlx4/qp.c
> +++ b/drivers/infiniband/hw/mlx4/qp.c
> @@ -792,6 +792,7 @@ static struct ib_qp *_mlx4_ib_create_qp_rss(struct ib_pd *pd,
>  	struct mlx4_ib_create_qp_rss ucmd = {};
>  	size_t required_cmd_sz;
>  	int err;
> +	int i;
>  
>  	if (!udata) {
>  		pr_debug("RSS QP with NULL udata\n");
> @@ -813,6 +814,10 @@ static struct ib_qp *_mlx4_ib_create_qp_rss(struct ib_pd *pd,
>  		return ERR_PTR(-EFAULT);
>  	}
>  
> +	for (i = 0; i < sizeof(ucmd.reserved); i++)
> +		if (ucmd.reserved[i])
> +			return ERR_PTR(-EOPNOTSUPP);
> +

Found this interesting function you might want to consider using:
/**
* memchr_inv - Find an unmatching character in an area of memory.
* @start: The memory area
* @c: Find a character other than c
* @bytes: The size of the area.
*
* returns the address of the first character other than @c, or %NULL
* if the whole buffer contains just @c.
*/
void *memchr_inv(const void *start, int c, size_t bytes)

>  	if (ucmd.comp_mask || ucmd.reserved1)
>  		return ERR_PTR(-EOPNOTSUPP);
>  
> -- 
> 2.14.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux