From patchwork Sun Aug 21 17:42:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9292623 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 23EA0600CB for ; Sun, 21 Aug 2016 17:43:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F54F288FA for ; Sun, 21 Aug 2016 17:43:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0032428974; Sun, 21 Aug 2016 17:43:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89AB1288FA for ; Sun, 21 Aug 2016 17:43:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752011AbcHURnG (ORCPT ); Sun, 21 Aug 2016 13:43:06 -0400 Received: from mout.web.de ([212.227.17.11]:64630 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751549AbcHURnF (ORCPT ); Sun, 21 Aug 2016 13:43:05 -0400 Received: from [192.168.1.3] ([77.181.85.179]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0MGzjq-1bOras419W-00DlYC; Sun, 21 Aug 2016 19:42:25 +0200 Subject: [PATCH 1/2] IB/core: Use memdup_user() rather than duplicating its implementation To: linux-rdma@vger.kernel.org, Doug Ledford , Hal Rosenstock , Sean Hefty References: <566ABCD9.1060404@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <7eb9ab74-b609-44d3-86f2-60137817aeed@users.sourceforge.net> Date: Sun, 21 Aug 2016 19:42:11 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:VmpBD4lAbd3WUC4b2M3P2OhSeZ8rh8RQsvfuyl0WvQmwcMoNc2+ bgHiLVYbbFisDS+Ik0gd+sNcVmVB1YxfIiBeltjie1EBgrULAcnrjZ2O+xE0nKNF+1KOxi/ q4YAI6sdvjAC13gLGSsP8w1Rs2REBktpVHCPsb7hUwTULfni3AmZ2onukSfldHVVrzGNqIP 8cOQmyfvIKz8SrEQl0pQA== X-UI-Out-Filterresults: notjunk:1; V01:K0:gukoQh70njA=:nCJt4Wu2xuJEEizGKgEGFJ 3vRL1TEXWsA3Ks5KU5GxChnqCWoYslGFWfNUwZNHDlSTR4yc5ErTFNjGQskM4XlTXVovPz6Ak R+ieRQD/gGvu4fETlwUIvz9j2CgGd3MQJKOJ3x2rdVUbXZcWjj5Ow6tPsOmaM8Uz4xy5Ns0MS eqxxxi89yNMQy/dlPVgyXSidQUHdkM4PksUHNanRQd0rZ2I04qglpwWN4jCHM2qyZ4lgWZ4If mrFLJ5S3J3PZjjgPbYVMLvQygKJDlxwOgSFD6yv7jmWSPWqid6BzJD9s5jah//ARzVpVxk92e +1pEe2jL5K9cczv6/DT7X4q12P2IQ8zZA5MlTMoxUUVwRPJs6c36KEprf0OshQGj8F+SW3VMr LS0eQ2TuRhFrns9lipU/jrMxI20F51lfC0NNmWEQ4ZORYghEVSZeZjrTooVd9H1ZnqXgBuBkX qDlCIQ25++aR9qIFzBQhLyiXFTvYqM0KM9mal2OT137r1RL2tPn3hKIEwOdqssoqujHICYoPE KMG51bR+QaE/5dRr9yk+KM8WG+WopS71V+1Go4SsKgt6CHrjdD0dJT0ERAx55cynjhKWjGky4 x9/PRJMVcFvXDpquHd01RaW8FHm+7HYaPC1kgsmhN24bCAxMjwceezzr704JzjJF/wyslG1VZ a0zXzq2K9jyqed7dpLmkJ6hYUCBLlHr8jy6a/HD1UEbCEIW7RwhRd2agV+r2RQP3ll8VbUW6R gIMAaXU6NygKjOD8pEFIxkjVnIjcMmMp809tVU0JG/aFV5ofwavtem/I3pL0kM8Py+m9HR82R 8RAuxxJ Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 21 Aug 2016 18:45:22 +0200 Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- include/rdma/ib_verbs.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 6f667dd..033610b 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h @@ -2205,16 +2205,11 @@ static inline bool ib_is_udata_cleared(struct ib_udata *udata, if (len > USHRT_MAX) return false; - buf = kmalloc(len, GFP_KERNEL); - if (!buf) + buf = memdup_user(p, len); + if (IS_ERR(buf)) return false; - if (copy_from_user(buf, p, len)) - goto free; - ret = !memchr_inv(buf, 0, len); - -free: kfree(buf); return ret; }