Received: by 10.223.185.116 with SMTP id b49csp2333030wrg; Mon, 5 Mar 2018 00:35:56 -0800 (PST) X-Google-Smtp-Source: AG47ELtPhCsI9QeV8rk3b5RFfDX5TJ9zCt/81SRqBU9+7SiqZuIGlp8R/Us3T3aNflQrCved0ujW X-Received: by 2002:a17:902:5819:: with SMTP id m25-v6mr12234819pli.248.1520238956724; Mon, 05 Mar 2018 00:35:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520238956; cv=none; d=google.com; s=arc-20160816; b=qgkqezF7WpB7jidqtnFacwQ64BjvtEx2wkNFFKp6rKYP2k26dJnJQi6V5y/PPInoMO rb33JkChgLIjlcrW2CwQXjfubLMEjyH6+srw2/dznQRVGma8T9l9JW4hOYlolNjm2fS6 H5nS17HbXrG/LW1gv2VPS0CGXo+3eLF3wn5eH31CNvJ1FdJuO0uzqfNjuS9mCIYJyumN L8JYxyV4b1Ug2sTe6doC7U26qRlBrvrfbRLwFW5uud+kZbQNvrq5DPj9OkUx8sroG2H9 BNPerjkDaQfxR2DdofFZTVsrDIh/VrVOcFsJTp7zjw/g7SbcBMSMeg68/XLBaRNU46ir wB/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:arc-authentication-results; bh=4EFInSmbhSd2LHKZnuOvrACq3Cie0fEaBwd162Drods=; b=IwtYghFyEgGsS49ckZN61JsfoRiMl8+ajQS/eX/TCt28izTOku5NUh6cWCDAyYrBLh R5F6OS7NTHCwFMpUYcPzm80qr+Y5r6lslcGqcr0ksJwyz++l1yPQDzqaCyw/31nEkgBX o+Q8ibKB9nqxd1Y6APj1iSPeu5hRQd/ENMrrgxqZ0hvWDI5ymG/dMnN2uGaXROy/VZBW zYPkIRM8+rhio8hZem3BmFFrxN5SfK+7BWr4suIcjOpoUDMCYYgeOVjnYAnZ3pmIss6u +tBS6gJuShaFY3lmFMkN9EJAS4RCZ4al47qQL4yks014rkv6AIPPaF/h/Vlf+LWeaUWT IWKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4-v6si9037678plh.540.2018.03.05.00.35.42; Mon, 05 Mar 2018 00:35:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933545AbeCEIbu (ORCPT + 99 others); Mon, 5 Mar 2018 03:31:50 -0500 Received: from mout.web.de ([212.227.17.12]:46725 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933522AbeCEIbr (ORCPT ); Mon, 5 Mar 2018 03:31:47 -0500 Received: from [192.168.1.2] ([92.228.188.109]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MBTEQ-1f13WD3qcw-00ARyS; Mon, 05 Mar 2018 09:31:36 +0100 Subject: [PATCH 1/4] scsi: hpsa: Use memdup_user() rather than duplicating its implementation From: SF Markus Elfring To: linux-scsi@vger.kernel.org, esc.storagedev@microsemi.com, Don Brace , "James E. J. Bottomley" , "Martin K. Petersen" Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: <1feebb55-05f4-a4f7-b478-efa57639c431@users.sourceforge.net> Date: Mon, 5 Mar 2018 09:31:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K0:LOZ12GGSBSDrYoLCHqIjjxItrGVqZVzFYQrZcVMjl8Ae85sG1YH +n9KShhXcR1mWcaz6PQ9y53cq3MIeTbLDEC0KtKrTVhETtsB7ImJ76nNhyHqFxbOpxvjCU2 UME6NcgswvHkpWnENcSsnLBsjCcHXpqC81bFieQ9ZQN5jmc0Qq1oWBbkaeN6k9T0KfLtVbo WP7SgjTrKQpoeoSTCaPyg== X-UI-Out-Filterresults: notjunk:1;V01:K0:aG67iMDnZTc=:nLo1depIsu1xYZtViIQNu9 v3sC4RBUyVyfsX43T+UfyG5B6OPKaASafyIniX6Df81HuB0oLeb3Zgal3mnC8e7NWpHJCHG28 zzDG1As1tMG/1KnWdEXVgjaf4AkGMJ5y1EUOXDMaKXk7wmBRSA0qqjFiW2vZ5CPAJEGUaszlo uFIVRZ0qTNQR7At5sM0AtvzcX5bwybIZr80NtlZV3zKJWFcC8Y0PLPQwRd/9GrbZEFHdUcEB+ th8EMumYEZp9/QdrAw3C+8y7gULEakOMR7RwPxVfbt+6MLX570JJSUt+qsvOnkgbztao2lMKt pUgs2yktDmVnyqZHltWWeqsOyD6pBzP4PuT6UvRaKEYYDLfUXBuaUF3z7fz+GE5u6wRNHFxqb ZBislOmo5LVGvUkmFSv/R6e/f96v9UBVwJtGJh9fi1XMOCbcD9LzJ5RIrZ1tAMi7Mub+T0O5w I3wjL5At7m0AOGBl99Ct4wG0MaV1ILrsuEwgnLn7bs1UDov6rhY8sXz6ub9/gm3HfV704+NSJ tASkOh5a745igD78bVfZhLgW5zcNY2BwuvoNiLIka1MKtImHY8FNWItKB8VKN91KIW/Cg2b6I Z8uchyQwP0QIc+kufN/xa+m+3Vnylfe+HUZfx5Sy8pZEVfFX/tKCp9yZPM3Eq/k5QwX3H6pv1 KqweyXWFVOWzqE/uVrZZJ4kCoB9OWczDXKxV7YWRGQbjaTWOtj+vUpb46P9Yn4i1rgnXBrx2I 6EbYl4C5r0um+BlYdJA7otKWvipM52/BmjDaF4SwXcur2AcVsYmFz7BdvhxXp8Cw6PMXEsWAQ L392x3pEXKd17XKADWiPcRAHKsn+DSv+1jQXSVnQUtnU19mLsw= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Sun, 4 Mar 2018 21:19:52 +0100 * Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. * Return directly after this function call failed at the beginning. Signed-off-by: Markus Elfring --- drivers/scsi/hpsa.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 5293e6827ce5..b35248becef9 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c @@ -6390,15 +6390,10 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) return -EINVAL; if (!capable(CAP_SYS_RAWIO)) return -EPERM; - ioc = kmalloc(sizeof(*ioc), GFP_KERNEL); - if (!ioc) { - status = -ENOMEM; - goto cleanup1; - } - if (copy_from_user(ioc, argp, sizeof(*ioc))) { - status = -EFAULT; - goto cleanup1; - } + ioc = memdup_user(argp, sizeof(*ioc)); + if (IS_ERR(ioc)) + return PTR_ERR(ioc); + if ((ioc->buf_size < 1) && (ioc->Request.Type.Direction != XFER_NONE)) { status = -EINVAL; -- 2.16.2