On 14/12/2015 18:31, Matan Barak wrote:
> I'm not sure regarding the string.c location, as it deals with user
> buffers, but in order not to
> be dependent on this, I'll change this code to the following.
>
> static inline bool ib_is_udata_cleared(struct ib_udata *udata,
> u8 cleared_char,
> size_t offset,
> size_t len)
> {
> const void __user *p = udata->inbuf + offset;
> bool ret = false;
> u8 *buf;
>
> if (len > USHRT_MAX)
> return false;
>
> buf = kmalloc(len, GFP_KERNEL);
> if (!buf)
> return false;
>
> if (copy_from_user(buf, p, len))
> goto free;
>
> ret = !memchr_inv(buf, cleared_char, len);
>
> free:
> kfree(buf);
> return ret;
> }
Looks good to me.
Thanks,
Haggai
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html