Received: by 10.213.65.68 with SMTP id h4csp1563724imn; Thu, 15 Mar 2018 03:25:02 -0700 (PDT) X-Google-Smtp-Source: AG47ELvdMCPNU/n0OXVsnkAgaCoo6xUDTv18W8V/HIMGNj0qhXF4n5fy1X1rSu/r/pH71IrihYk6 X-Received: by 10.99.112.77 with SMTP id a13mr6313830pgn.253.1521109501987; Thu, 15 Mar 2018 03:25:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521109501; cv=none; d=google.com; s=arc-20160816; b=n//4mKmy9WNKqNe1D5JES6CaKAHBHQ0cHUg4SMoOhgn8tExI6XfARfr26VpWGpBu9R haRVg941OYiZcw7OWmVSVTZQPzYIKChzk34vvM/XBHM1+LJBa94ALciCGU0rPgrGzZef Iu/ryVvn/JF/NPzh9xnRiM8fOSu0p5q5uO6SD9nTfSs5OKuR3pGPL1jprLwsOztObSiB j5CbSZG8RvDmZ3NA/Z+ZhgdjWaUkmFnWP3f3vFcLdJhcjoMkRcqcjd00uGM3Zb+Z95U4 ePt46R9Hbkwk1kq0H757ByBEBWFHWxGQyyanFwNac+SENmc7fdE4oxY5stFRWH1X8X14 CFfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=B++a2mxKRS1+yfQyZJakhQi5DbJKQD0EFyS94T5yCU8=; b=vg3zJScxlS4jDxqBGn/LJKoSYlHRyEOH8yw6MHD15rlV9Gp86BBQO6jSj8ps6h7JdY wTQmFPTyy8SJl8u6qSh0n1wRzi2qtSbnMArEB2d8iE7LunYBLvI0hPFjpgqGjGGibNtz SyCYh3H3xxnx7Wf8iZxvCOYK7vNMMFUNEU6TJ46TMfWZmTBQykNVpoYaJ1t1E8ahPB89 zI/yA1/vOZ+g/1IbEFwGcDWilB7DCZJAbyYdVWwQsNGv5+F8t8sqNrEQkptg/SeeLKDp emykZ1vly7C2Tltf5KspzXddVx9UTpcEvbSjeHQAvgFCfeBJQFe7ZVjC7i4rirrxs5f/ H/3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a+N/b5em; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i33-v6si3752904pld.212.2018.03.15.03.24.47; Thu, 15 Mar 2018 03:25:01 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=a+N/b5em; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752011AbeCOKXg (ORCPT + 99 others); Thu, 15 Mar 2018 06:23:36 -0400 Received: from mail-it0-f65.google.com ([209.85.214.65]:37170 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751828AbeCOKXb (ORCPT ); Thu, 15 Mar 2018 06:23:31 -0400 Received: by mail-it0-f65.google.com with SMTP id k79-v6so8527064ita.2 for ; Thu, 15 Mar 2018 03:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=B++a2mxKRS1+yfQyZJakhQi5DbJKQD0EFyS94T5yCU8=; b=a+N/b5em7Bo3p3i6WC10tKchtImXaTRDCad/FdLQm3zYKnY9AsSM7LaWokYKJ75edI fQr8Gdor8eHItA0olSGN7AVA6EUQZb+iK+Op2GTnkqWxyRmefTkomm9Zjyy7+Gq7QbfQ fvfhShJ1s5+bkzpSdTZh34Hz3elJo2qZco51Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=B++a2mxKRS1+yfQyZJakhQi5DbJKQD0EFyS94T5yCU8=; b=NDwK4yH83kGaJkM/i5ey9Z3LZIHrrkU2xYgmEiIeQr/Vq+RxErJKeu7HZdR7Avb869 5hdBZHCmi4hdn4kzS4+Q6XeMGncCXUapP9pDGxqyAE+g6fx/MOU1SDkPpRKRe+2Oub0a Ede4Q/uikZw97sPiUBTAcCYMoh+sRy92xedczG9xNBKgpQG3DUpKf8JEPYbI0QQPSdF3 zRv3MjVL3p6cSNtOGOKQCh+ajhv/GOOnd5fTvF7lcIwVgfp44Ub7AMs5Fl89Lw84zUnJ THucqAvWgwjhS3mDDX1JsFrCr1ik2lNMLpj7km8FBUu/Og5qGrFpFT0IA6xnBIo0ppqB yDOw== X-Gm-Message-State: AElRT7H+y/wE+2G0SE7qIAJkm50oGLvwbQh4pmnjkSRy6Njyr4QFCYXZ ZshwdjEX0/OjA2Y/gXYBryryHja8VdomHC2tPnMNtg== X-Received: by 2002:a24:d8c3:: with SMTP id b186-v6mr5451085itg.86.1521109411261; Thu, 15 Mar 2018 03:23:31 -0700 (PDT) MIME-Version: 1.0 Received: by 10.2.101.23 with HTTP; Thu, 15 Mar 2018 03:23:30 -0700 (PDT) In-Reply-To: <4eca7388-cb2d-31e0-b64d-afb30818f53e@users.sourceforge.net> References: <4eca7388-cb2d-31e0-b64d-afb30818f53e@users.sourceforge.net> From: Ulf Hansson Date: Thu, 15 Mar 2018 11:23:30 +0100 Message-ID: Subject: Re: [PATCH] mmc/core/block: Use memdup_user() rather than duplicating its implementation To: SF Markus Elfring Cc: "linux-mmc@vger.kernel.org" , Adrian Hunter , Linus Walleij , Shawn Lin , LKML , kernel-janitors@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5 March 2018 at 13:08, SF Markus Elfring wrote: > From: Markus Elfring > Date: Mon, 5 Mar 2018 11:33:21 +0100 > > 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 Thanks, applied for next! Kind regards Uffe > --- > drivers/mmc/core/block.c | 15 ++++----------- > 1 file changed, 4 insertions(+), 11 deletions(-) > > diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c > index 20135a5de748..4b09c7380e70 100644 > --- a/drivers/mmc/core/block.c > +++ b/drivers/mmc/core/block.c > @@ -375,22 +375,15 @@ static struct mmc_blk_ioc_data *mmc_blk_ioctl_copy_from_user( > return idata; > } > > - idata->buf = kmalloc(idata->buf_bytes, GFP_KERNEL); > - if (!idata->buf) { > - err = -ENOMEM; > + idata->buf = memdup_user((void __user *)(unsigned long) > + idata->ic.data_ptr, idata->buf_bytes); > + if (IS_ERR(idata->buf)) { > + err = PTR_ERR(idata->buf); > goto idata_err; > } > > - if (copy_from_user(idata->buf, (void __user *)(unsigned long) > - idata->ic.data_ptr, idata->buf_bytes)) { > - err = -EFAULT; > - goto copy_err; > - } > - > return idata; > > -copy_err: > - kfree(idata->buf); > idata_err: > kfree(idata); > out: > -- > 2.16.2 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-mmc" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html