Re: [PATCH 03/10] RDMA: Add ib_respond_udata()

Jason Gunthorpe
2026-02-13T15:48:20Z

On Fri, Feb 13, 2026 at 05:37:39PM +0200, Leon Romanovsky wrote:
> On Fri, Feb 13, 2026 at 08:43:59AM -0400, Jason Gunthorpe wrote:
> > On Fri, Feb 13, 2026 at 12:10:53PM +0200, Leon Romanovsky wrote:
> > > > @@ -3177,6 +3177,38 @@ static inline int _ib_copy_validate_udata_in(struct ib_udata *udata, void *req,
> > > > ret; \
> > > > })
> > > >
> > > > +static inline int _ib_respond_udata(struct ib_udata *udata, const void *src,
> > > > + size_t len)
> > > > +{
> > > > + size_t copy_len;
> > > > +
> > > > + copy_len = min(len, udata->outlen);
> > >
> > > Don't you need to check that udata->outlen is larger than zero?
> >
> > As far as I can tell 0 works fine with copy_to_user()
>
> My main concern that it is not clear what return value will be in that
> case.
>
> + copy_len = min(len, udata->outlen);
> + if (copy_to_user(udata->outbuf, src, copy_len))
> + return -EFAULT; <--- this?
> + if (copy_len < udata->outlen) {
> ...
> + }
> + return 0; <- or this?

Oh, yeah, that's a really good point.

Jason