From patchwork Mon Aug 22 08:40:56 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: 9293207 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 B18CA60574 for ; Mon, 22 Aug 2016 08:41:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A08C7287C9 for ; Mon, 22 Aug 2016 08:41:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 951E52887D; Mon, 22 Aug 2016 08:41:28 +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=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7764287C9 for ; Mon, 22 Aug 2016 08:41:27 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id EA436266848; Mon, 22 Aug 2016 10:41:26 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id DBD552667C4; Mon, 22 Aug 2016 10:41:18 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id AA1F82667C4; Mon, 22 Aug 2016 10:41:17 +0200 (CEST) Received: from mout.web.de (mout.web.de [217.72.192.78]) by alsa0.perex.cz (Postfix) with ESMTP id 9878626673E for ; Mon, 22 Aug 2016 10:41:10 +0200 (CEST) Received: from [192.168.1.3] ([77.182.220.187]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0LoHcD-1aw4J845VZ-00gEyx; Mon, 22 Aug 2016 10:41:00 +0200 To: alsa-devel@alsa-project.org, Jaroslav Kysela , Joe Perches , Takashi Iwai , Vinod Koul References: <566ABCD9.1060404@users.sourceforge.net> <7233eb00-a941-4935-dce2-7cb907272d41@users.sourceforge.net> <03eac1fe-ff33-1759-9c2a-7914f1c6de45@users.sourceforge.net> <1471809094.3746.17.camel@perches.com> <14b1efe1-3c1c-4c36-bfc2-19947c190412@users.sourceforge.net> From: SF Markus Elfring Message-ID: <85977ca3-562e-0a49-0189-53e0ebcdde0c@users.sourceforge.net> Date: Mon, 22 Aug 2016 10:40:56 +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: <14b1efe1-3c1c-4c36-bfc2-19947c190412@users.sourceforge.net> X-Provags-ID: V03:K0:8yar1t0bfVP6SOCp/J6Tiw89KHmzEttI/JHNLy7aYVKvA2TnzrD pQzTHNUP4mXt2EEYKSzLi9SxNfrlQIk2eQO+AK1ugTdrS+iLdERdstNYSkHsuofVsyJZbXR /i4E+BhUwS6tjAzUxBotfH1cGkZuidDoBx0QImF5dAAQREfC5g8zNVQAmIeu0lOTT0eLXV8 Ac1IsNe/RXXizS0hnIFLw== X-UI-Out-Filterresults: notjunk:1; V01:K0:ccPBs2notYU=:r0hJfLPczoladJ3Puve473 qVhxCBVnuDcypEMiRqk+dKzoQnRCHDLb2w8g/FAZMiMG6dzxrRg3mKfjUK7AhQUIlFMmVs0L7 IGPUlvhXlRLixveNqhQiAKU3z14tJjVSCXhWx3Y0c+3NtSxhGrMfNmY7+smNFiTeKx0EvGREH a15QqQR0h+EJQrI0Gst6oAigj/URbBjaIkMrcJr02yC0NXYPSJAefJHBD1/G+AFLbLneQLqO5 lcdNzusxzoKrSTuSHXgxjhjBXdTZ7Iu0jcitEd1/c2F9X1+EynpdZ1oY+sodnanu0eTWse0Ih 01tj7EDjx5yHWBv8tf6WBZCbK85IfgbBFg5rmPBYJ6VFbr2DtTBuOiYlHLmXG/6pYrJxuqpmv j/ccE7OqDhY02eYTwzSgswuqCK4FPzhWvvQjn6xHKm6F9TB0t/ipNuzcNIH+qaYy1lJxLJ0cy jHcVCwTbmXMRWOj15KQMdvEt/Fr2YpjuAQHLxbHJZaNMgCPuTUuphUPvNEiGvfX6crF4tY8Sq ryD7Pzt2z1A9lQA7ZYZYEuTdPpJnaqm9sWJO8AkPWO9QRqjRtfwQezSDBumglQLaU1uLAd7kW UZ0r4umNqNzpN5UoGD5alVm1HSliN6QF2+jvsrJkBDFHFa1EGX/WRufzUh+T8UatpH3/fvDmf S0n92hukKhSD4P1lnPi7WsRqPVeZdzTrgM74Z8Xwz9R9PX+3n4+ZkoFI43gQHGztB1DhvEWBX DZYXjvxK+nGiPxwV5n7hOtwxs6qtepF1LSI9G0pqss7OnSc+gyLGq3DMpKU9MpDLI6xfUAdds MPP82sj Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH v2 2/2] ALSA: compress: Use memdup_user() rather than duplicating its implementation X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Mon, 22 Aug 2016 10:12:37 +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 --- sound/core/compress_offload.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index a10d139..786989b 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -554,13 +554,9 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg) * we should allow parameter change only when stream has been * opened not in other cases */ - params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) - return -ENOMEM; - if (copy_from_user(params, (void __user *)arg, sizeof(*params))) { - retval = -EFAULT; - goto out; - } + params = memdup_user((void __user *)arg, sizeof(*params)); + if (IS_ERR(params)) + return PTR_ERR(params); retval = snd_compress_check_input(params); if (retval)