Re: [PATCH 04/10] RDMA: Add ib_is_udata_in_empty()

Leon Romanovsky
2026-02-13T10:22:45Z

On Thu, Feb 05, 2026 at 09:45:38PM -0400, Jason Gunthorpe wrote:
> If the driver doesn't yet support any request driver data it should check
> that it is all zeroed. This is a common pattern, add a helper to do this.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> include/rdma/ib_verbs.h | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index c0dd82a77e7a13..973d9ec6875e63 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -3119,6 +3119,20 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata,
> return ib_is_buffer_cleared(udata->inbuf + offset, len);
> }
>
> +/**
> + * ib_is_udata_in_empty - Check if the udata is empty
> + * @udata: The system calls ib_udata struct
> + *
> + * This should be used if the driver does not currently define a driver data
> + * struct.
> + */
> +static inline bool ib_is_udata_in_empty(struct ib_udata *udata)
> +{
> + if (udata && udata->inlen != 0)
> + return ib_is_buffer_cleared(udata->inbuf, udata->inlen);

The number of existing callers of ib_is_buffer_cleared() and very
similar ib_is_udata_cleared() check caused me to think that udata->inlen
!= 0 needs to be checked in ib_is_buffer_cleared().

For example, we don't have this != 0 check in uverbs_request_finish().

Thanks

> + return true;
> +}
> +
> static inline int _ib_copy_validate_udata_in(struct ib_udata *udata, void *req,
> size_t kernel_size,
> size_t minimum_size)
> --
> 2.43.0
>