All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Cc: devel@driverdev.osuosl.org, Fengguang Wu <fengguang.wu@intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] staging: i4l: icn: use memdup_user
Date: Tue, 23 Aug 2016 06:50:30 -0400	[thread overview]
Message-ID: <20160823105030.GA11124@kroah.com> (raw)
In-Reply-To: <1471948054-15651-1-git-send-email-sudipm.mukherjee@gmail.com>

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 <fengguang.wu@intel.com>
> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
> ---
>  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

  reply	other threads:[~2016-08-23 10:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-23 10:27 [PATCH] staging: i4l: icn: use memdup_user Sudip Mukherjee
2016-08-23 10:50 ` Greg Kroah-Hartman [this message]
2016-08-23 10:58   ` Sudip Mukherjee
2016-08-23 13:07     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160823105030.GA11124@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=devel@driverdev.osuosl.org \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudipm.mukherjee@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.