public inbox for linux-rdma@vger.kernel.org
 help / color / mirror / Atom feed
From: Or Gerlitz <ogerlitz@mellanox.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Eli Cohen <eli@mellanox.com>,
	linux-rdma@vger.kernel.org, kernel-janitors@vger.kernel.org,
	Jack Morgenstein <jackm@dev.mellanox.co.il>,
	Moshe Lazer <moshel@mellanox.com>
Subject: Re: [patch -next] mlx5_core: return -EFAULT if copy_to_user() fails
Date: Wed, 10 Jul 2013 14:37:03 +0300	[thread overview]
Message-ID: <51DD475F.4060402@mellanox.com> (raw)
In-Reply-To: <20130710105714.GC31232@longonot.mountain>

On 10/07/2013 13:57, Dan Carpenter wrote:
> This should return an error code instead of the number of bytes
> remaining to be copied.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
> index a550a8e..4273c06 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/debugfs.c
> @@ -148,7 +148,6 @@ static ssize_t average_read(struct file *filp, char __user *buf, size_t count,
>   	struct mlx5_cmd_stats *stats;
>   	u64 field = 0;
>   	int ret;
> -	int err;
>   	char tbuf[22];
>   
>   	if (*pos)
> @@ -161,9 +160,8 @@ static ssize_t average_read(struct file *filp, char __user *buf, size_t count,
>   	spin_unlock(&stats->lock);
>   	ret = snprintf(tbuf, sizeof(tbuf), "%llu\n", field);
>   	if (ret > 0) {
> -		err = copy_to_user(buf, tbuf, ret);
> -		if (err)
> -			return err;
> +		if (copy_to_user(buf, tbuf, ret))
> +			return -EFAULT;
>   	}
>   
>   	*pos += ret;
> @@ -418,7 +416,6 @@ static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count,
>   	char tbuf[18];
>   	u64 field;
>   	int ret;
> -	int err;
>   
>   	if (*pos)
>   		return 0;
> @@ -445,9 +442,8 @@ static ssize_t dbg_read(struct file *filp, char __user *buf, size_t count,
>   
>   	ret = snprintf(tbuf, sizeof(tbuf), "0x%llx\n", field);
>   	if (ret > 0) {
> -		err = copy_to_user(buf, tbuf, ret);
> -		if (err)
> -			return err;
> +		if (copy_to_user(buf, tbuf, ret))
> +			return -EFAULT;
>   	}
>   
>   	*pos += ret;
>

ditto here

Acked-by: Or Gerlitz <ogerlitz@mellanox.com>

      reply	other threads:[~2013-07-10 11:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10 10:57 [patch -next] mlx5_core: return -EFAULT if copy_to_user() fails Dan Carpenter
2013-07-10 11:37 ` Or Gerlitz [this message]

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=51DD475F.4060402@mellanox.com \
    --to=ogerlitz@mellanox.com \
    --cc=dan.carpenter@oracle.com \
    --cc=eli@mellanox.com \
    --cc=jackm@dev.mellanox.co.il \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=moshel@mellanox.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox