From patchwork Sun Aug 21 07:19:04 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: 9292041 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 E57CE607F0 for ; Sun, 21 Aug 2016 07:19:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D15E528BAE for ; Sun, 21 Aug 2016 07:19:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C66A828BB1; Sun, 21 Aug 2016 07:19:45 +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 7D62728BAE for ; Sun, 21 Aug 2016 07:19:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752087AbcHUHTa (ORCPT ); Sun, 21 Aug 2016 03:19:30 -0400 Received: from mout.web.de ([212.227.17.12]:60737 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751121AbcHUHT3 (ORCPT ); Sun, 21 Aug 2016 03:19:29 -0400 Received: from [192.168.1.3] ([77.181.85.179]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0Lba35-1ard4q0bnv-00lChs; Sun, 21 Aug 2016 09:19:07 +0200 Subject: [PATCH 1/7] aacraid: Use memdup_user() rather than duplicating its implementation To: linux-scsi@vger.kernel.org, aacraid@microsemi.com, "James E. J. Bottomley" , "Martin K. Petersen" References: <566ABCD9.1060404@users.sourceforge.net> <40d8607f-3934-c31f-3791-ef6a67d65d45@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <23c56a66-74a6-6033-f209-ac3e4ba83e61@users.sourceforge.net> Date: Sun, 21 Aug 2016 09:19:04 +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: <40d8607f-3934-c31f-3791-ef6a67d65d45@users.sourceforge.net> X-Provags-ID: V03:K0:lr4/N07YSOsZy+uWTilO4ZgmfIOV6CHIbdZAy7CYAubfHS4Qolq aLXVCGyWTfWemwiHPDVexX2lDjU25IkJLsdFdCrkgeSaVKVe3aXY5Rs6+zrZ9cJHq8y2yix 6kd404ZciAV2xJPTj0TDwOmJ4BZb+FKdJzg2QFY+FiXGsC5Fr95u9CQgRm3KZS+SXt7JNEt V68pAqz73lJ+vBN5U90Og== X-UI-Out-Filterresults: notjunk:1; V01:K0:S06n8tc7Z6A=:8WT2D7ksY6a7KvklDgmOfv ry5Wto0nu1+dNJSgNCDXQHCCqV6L4kDCnZv2r0MAqezCTUA87bd96+syJVzieAp+JmgmLqfuz d7QyDeIH8ivW4VPLcRJEjFojvCrS/knlUVMuh+o4rgFYbqpItiiIwsW0lsZj80dSA5reQKAYZ 6NMSPfVqp0ClzELC7PMju+b2DbEfYgbohwdI43dtgxGw+U/zSITG8XqIwnNnyF9fsG6aQX8T3 6LSoPDz3AFncJ54ROxeYCANeoOnGfPgMi8Yls/0SyNiRuiMclK/dNNnoGuHVPEOaqsSzZSFGK aA/abVeT52oSK8SwrzYeK+3kKX5KcG8h1m/Vh/OsiH8AnpX90hAillpSMfuvuwyW3Ckand7Kh p9j6kKJdDDLeFACL4N/HBebK1IuMQQZSWiX6SYW0yyvUXi+X1fOTVUdJwkSADhy5/fZIl0MVF ZrnrgHsrpD4x8q6FNK49PAffil/8ut/+V592Dy1ejDSbK8fRWlrPhBDgDqGEHCMDIG6EqQe/o japP/LQHRMw7ecSiT9AiFCsTidef0eUnUJCGUiuqzP9QMcuWdXUY5K+kXRUYX5iKf9Uue0jwn tUj6JFEv3e3pUCj3rSHrZS8jxf0S4HfHSciDF9mcSYchfnMW6H/AWd+X6YD988B+t2VJcCKxn aWhXwB4WJaGcHB08Vv5OXRPo68xdsQnDmah2Pu72wBSMxIlMjx+8O1NcslyEJFo/z4pQww0mb KBJSlJS/8RCurfpMu6D9B0jldrYeDSdaYDEiDxoqCSr80zWG5SULQn7uC5EvD9ogP+DM98h1L vejwKEh Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 20 Aug 2016 20:05:24 +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 --- drivers/scsi/aacraid/commctrl.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c index 5648b71..1af3084 100644 --- a/drivers/scsi/aacraid/commctrl.c +++ b/drivers/scsi/aacraid/commctrl.c @@ -526,15 +526,9 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg) goto cleanup; } - user_srbcmd = kmalloc(fibsize, GFP_KERNEL); - if (!user_srbcmd) { - dprintk((KERN_DEBUG"aacraid: Could not make a copy of the srb\n")); - rcode = -ENOMEM; - goto cleanup; - } - if(copy_from_user(user_srbcmd, user_srb,fibsize)){ - dprintk((KERN_DEBUG"aacraid: Could not copy srb from user\n")); - rcode = -EFAULT; + user_srbcmd = memdup_user(user_srb, fibsize); + if (IS_ERR(user_srbcmd)) { + rcode = PTR_ERR(user_srbcmd); goto cleanup; }