From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757598AbcHWKuY (ORCPT ); Tue, 23 Aug 2016 06:50:24 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:36282 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754089AbcHWKuW (ORCPT ); Tue, 23 Aug 2016 06:50:22 -0400 Date: Tue, 23 Aug 2016 06:50:30 -0400 From: Greg Kroah-Hartman To: Sudip Mukherjee Cc: devel@driverdev.osuosl.org, Fengguang Wu , linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: i4l: icn: use memdup_user Message-ID: <20160823105030.GA11124@kroah.com> References: <1471948054-15651-1-git-send-email-sudipm.mukherjee@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1471948054-15651-1-git-send-email-sudipm.mukherjee@gmail.com> User-Agent: Mutt/1.7.0 (2016-08-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 23, 2016 at 03:57:34PM +0530, Sudip Mukherjee wrote: > Its better to use memdup_user which does the same thing which this > code has implemented. > > Suggested-by: Fengguang Wu > Signed-off-by: Sudip Mukherjee > --- > drivers/staging/i4l/icn/icn.c | 16 +++++----------- > 1 file changed, 5 insertions(+), 11 deletions(-) > > diff --git a/drivers/staging/i4l/icn/icn.c b/drivers/staging/i4l/icn/icn.c > index b2f4055..5312675 100644 > --- a/drivers/staging/i4l/icn/icn.c > +++ b/drivers/staging/i4l/icn/icn.c > @@ -804,21 +804,16 @@ static int > icn_loadboot(u_char __user *buffer, icn_card *card) > { > int ret; > - u_char *codebuf; > + void *codebuf; why did you change the type here? > unsigned long flags; > > #ifdef BOOT_DEBUG > printk(KERN_DEBUG "icn_loadboot called, buffaddr=%08lx\n", (ulong) buffer); > #endif > - codebuf = kmalloc(ICN_CODE_STAGE1, GFP_KERNEL); > - if (!codebuf) { > - printk(KERN_WARNING "icn: Could not allocate code buffer\n"); > - ret = -ENOMEM; > - goto out; > - } > - if (copy_from_user(codebuf, buffer, ICN_CODE_STAGE1)) { > - ret = -EFAULT; > - goto out_kfree; > + codebuf = memdup_user(buffer, ICN_CODE_STAGE1); > + if (IS_ERR(codebuf)) { > + pr_warn("icn: Could not allocate code buffer\n"); Don't warn about something that already was warned about. thanks, greg k-h