From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752671AbcHUKAG (ORCPT ); Sun, 21 Aug 2016 06:00:06 -0400 Received: from [195.159.176.226] ([195.159.176.226]:39572 "EHLO blaine.gmane.org" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1751905AbcHUKAF (ORCPT ); Sun, 21 Aug 2016 06:00:05 -0400 X-Injected-Via-Gmane: http://gmane.org/ To: linux-kernel@vger.kernel.org From: Christophe JAILLET Subject: Re: [PATCH] staging/lustre/llite: Use memdup_user() rather than duplicating its implementation Date: Sun, 21 Aug 2016 11:59:23 +0200 Message-ID: <66b32046-56ee-430e-e80e-1cdd5a8e68c4@wanadoo.fr> References: <566ABCD9.1060404@users.sourceforge.net> <73da135c-be81-e915-9b7a-6773e730b4e7@users.sourceforge.net> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@blaine.gmane.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 Cc: lustre-devel@clusterfs.com, kernel-janitors@vger.kernel.org In-Reply-To: <73da135c-be81-e915-9b7a-6773e730b4e7@users.sourceforge.net> X-Antivirus: avast! (VPS 160820-1, 20/08/2016), Outbound message X-Antivirus-Status: Clean Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 21/08/2016 à 11:45, SF Markus Elfring a écrit : > From: Markus Elfring > Date: Sun, 21 Aug 2016 11:30:57 +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/staging/lustre/lustre/llite/dir.c | 12 +++--------- > 1 file changed, 3 insertions(+), 9 deletions(-) > > diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c > index 031c9e4..8b70e42 100644 > --- a/drivers/staging/lustre/lustre/llite/dir.c > +++ b/drivers/staging/lustre/lustre/llite/dir.c > @@ -1676,14 +1676,9 @@ out_poll: > case LL_IOC_QUOTACTL: { > struct if_quotactl *qctl; > > - qctl = kzalloc(sizeof(*qctl), GFP_NOFS); Same as previously reported in another patch, GFP_NOFS has not the same meaning than GPF_KERNEL. So your proposed clean-up is not 100% equivalent. Are your sure that GPF_KERNEL instead of GFP_NOFS is right in this code? Maybe, the coccinelle check should be tweak to only spot "kzalloc(..., GFP_KERNEL)" allocation? > - if (!qctl) > - return -ENOMEM; > - > - if (copy_from_user(qctl, (void __user *)arg, sizeof(*qctl))) { > - rc = -EFAULT; > - goto out_quotactl; > - } > + qctl = memdup_user((void __user *)arg, sizeof(*qctl)); > + if (IS_ERR(qctl)) > + return PTR_ERR(qctl); > > rc = quotactl_ioctl(sbi, qctl); > > @@ -1691,7 +1686,6 @@ out_poll: > sizeof(*qctl))) > rc = -EFAULT; > > -out_quotactl: > kfree(qctl); > return rc; > } --- L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast. https://www.avast.com/antivirus