From mboxrd@z Thu Jan 1 00:00:00 1970 From: Haggai Eran Subject: Re: [PATCH for-next V1 2/5] IB/core: Add ib_is_udata_cleared Date: Tue, 15 Dec 2015 16:13:55 +0200 Message-ID: <56702023.5080307@mellanox.com> References: <1449157463-25313-1-git-send-email-matanb@mellanox.com> <1449157463-25313-3-git-send-email-matanb@mellanox.com> <56658718.8080308@mellanox.com> <5669983E.5000200@mellanox.com> <566D9315.9050807@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Matan Barak Cc: Matan Barak , Eli Cohen , linux-rdma , Doug Ledford , Eran Ben Elisha , Yann Droneaud List-Id: linux-rdma@vger.kernel.org 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 majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html