From: "Christian König" <christian.koenig@amd.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Alex Deucher <alexander.deucher@amd.com>
Cc: "David \(ChunMing\) Zhou" <David1.Zhou@amd.com>,
Jonathan Kim <Jonathan.Kim@amd.com>,
Philip Yang <Philip.Yang@amd.com>,
David Airlie <airlied@linux.ie>,
Felix Kuehling <Felix.Kuehling@amd.com>,
"Tianci.Yin" <tianci.yin@amd.com>,
kernel-janitors@vger.kernel.org, amd-gfx@lists.freedesktop.org,
dri-devel@lists.freedesktop.org, Daniel Vetter <daniel@ffwll.ch>
Subject: Re: [PATCH] drm/amdgpu: return -EFAULT if copy_to_user() fails
Date: Wed, 12 Feb 2020 13:12:17 +0100 [thread overview]
Message-ID: <577d76db-3c2d-545d-6237-1c66f17ec178@amd.com> (raw)
In-Reply-To: <20200212120759.dokjxbk4cqln55sc@kili.mountain>
Am 12.02.20 um 13:07 schrieb Dan Carpenter:
> The copy_to_user() function returns the number of bytes remaining to be
> copied, but we want to return a negative error code to the user.
>
> Fixes: 030d5b97a54b ("drm/amdgpu: use amdgpu_device_vram_access in amdgpu_ttm_vram_read")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Alex do you want to pick that up or should I do this?
Thanks,
Christian.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 15f5451d312d..660867cf2597 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -2280,7 +2280,6 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf,
> {
> struct amdgpu_device *adev = file_inode(f)->i_private;
> ssize_t result = 0;
> - int r;
>
> if (size & 0x3 || *pos & 0x3)
> return -EINVAL;
> @@ -2294,9 +2293,8 @@ static ssize_t amdgpu_ttm_vram_read(struct file *f, char __user *buf,
> uint32_t value[AMDGPU_TTM_VRAM_MAX_DW_READ];
>
> amdgpu_device_vram_access(adev, *pos, value, bytes, false);
> - r = copy_to_user(buf, value, bytes);
> - if (r)
> - return r;
> + if (copy_to_user(buf, value, bytes))
> + return -EFAULT;
>
> result += bytes;
> buf += bytes;
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2020-02-12 12:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-12 12:07 [PATCH] drm/amdgpu: return -EFAULT if copy_to_user() fails Dan Carpenter
2020-02-12 12:12 ` Christian König [this message]
2020-02-12 17:48 ` Alex Deucher
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=577d76db-3c2d-545d-6237-1c66f17ec178@amd.com \
--to=christian.koenig@amd.com \
--cc=David1.Zhou@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=Jonathan.Kim@amd.com \
--cc=Philip.Yang@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dan.carpenter@oracle.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=tianci.yin@amd.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;
as well as URLs for NNTP newsgroup(s).