* [PATCH] drm/v3d: fix copy_from_user() error codes
@ 2021-10-11 12:33 Dan Carpenter
2021-10-11 12:59 ` Melissa Wen
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-10-11 12:33 UTC (permalink / raw)
To: Emma Anholt, Melissa Wen
Cc: David Airlie, Daniel Vetter, Iago Toral Quiroga, dri-devel,
kernel-janitors
The copy_to/from_user() function returns the number of bytes remaining
to be copied, but we want to return -EFAULT on error.
Fixes: e4165ae8304e ("drm/v3d: add multiple syncobjs support")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/gpu/drm/v3d/v3d_gem.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
index 6a000d77c568..e47ae40a865a 100644
--- a/drivers/gpu/drm/v3d/v3d_gem.c
+++ b/drivers/gpu/drm/v3d/v3d_gem.c
@@ -487,8 +487,8 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
for (i = 0; i < se->in_sync_count; i++) {
struct drm_v3d_sem in;
- ret = copy_from_user(&in, handle++, sizeof(in));
- if (ret) {
+ if (copy_from_user(&in, handle++, sizeof(in))) {
+ ret = -EFAULT;
DRM_DEBUG("Failed to copy wait dep handle.\n");
goto fail_deps;
}
@@ -609,8 +609,8 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv,
for (i = 0; i < count; i++) {
struct drm_v3d_sem out;
- ret = copy_from_user(&out, post_deps++, sizeof(out));
- if (ret) {
+ if (copy_from_user(&out, post_deps++, sizeof(out))) {
+ ret = -EFAULT;
DRM_DEBUG("Failed to copy post dep handles\n");
goto fail;
}
@@ -646,9 +646,8 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,
struct v3d_submit_ext *se = data;
int ret;
- ret = copy_from_user(&multisync, ext, sizeof(multisync));
- if (ret)
- return ret;
+ if (copy_from_user(&multisync, ext, sizeof(multisync)))
+ return -EFAULT;
if (multisync.pad)
return -EINVAL;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/v3d: fix copy_from_user() error codes
2021-10-11 12:33 [PATCH] drm/v3d: fix copy_from_user() error codes Dan Carpenter
@ 2021-10-11 12:59 ` Melissa Wen
0 siblings, 0 replies; 2+ messages in thread
From: Melissa Wen @ 2021-10-11 12:59 UTC (permalink / raw)
To: Dan Carpenter
Cc: Emma Anholt, David Airlie, Daniel Vetter, Iago Toral Quiroga,
dri-devel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1888 bytes --]
On 10/11, Dan Carpenter wrote:
> The copy_to/from_user() function returns the number of bytes remaining
> to be copied, but we want to return -EFAULT on error.
>
> Fixes: e4165ae8304e ("drm/v3d: add multiple syncobjs support")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> drivers/gpu/drm/v3d/v3d_gem.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/v3d_gem.c
> index 6a000d77c568..e47ae40a865a 100644
> --- a/drivers/gpu/drm/v3d/v3d_gem.c
> +++ b/drivers/gpu/drm/v3d/v3d_gem.c
> @@ -487,8 +487,8 @@ v3d_job_init(struct v3d_dev *v3d, struct drm_file *file_priv,
> for (i = 0; i < se->in_sync_count; i++) {
> struct drm_v3d_sem in;
>
> - ret = copy_from_user(&in, handle++, sizeof(in));
> - if (ret) {
> + if (copy_from_user(&in, handle++, sizeof(in))) {
> + ret = -EFAULT;
> DRM_DEBUG("Failed to copy wait dep handle.\n");
> goto fail_deps;
> }
> @@ -609,8 +609,8 @@ v3d_get_multisync_post_deps(struct drm_file *file_priv,
> for (i = 0; i < count; i++) {
> struct drm_v3d_sem out;
>
> - ret = copy_from_user(&out, post_deps++, sizeof(out));
> - if (ret) {
> + if (copy_from_user(&out, post_deps++, sizeof(out))) {
> + ret = -EFAULT;
> DRM_DEBUG("Failed to copy post dep handles\n");
> goto fail;
> }
> @@ -646,9 +646,8 @@ v3d_get_multisync_submit_deps(struct drm_file *file_priv,
> struct v3d_submit_ext *se = data;
> int ret;
>
> - ret = copy_from_user(&multisync, ext, sizeof(multisync));
> - if (ret)
> - return ret;
> + if (copy_from_user(&multisync, ext, sizeof(multisync)))
> + return -EFAULT;
>
> if (multisync.pad)
> return -EINVAL;
Hi Dan,
Thanks for catching this.
Reviewed-by: Melissa Wen <mwen@igalia.com>
> --
> 2.20.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-11 13:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 12:33 [PATCH] drm/v3d: fix copy_from_user() error codes Dan Carpenter
2021-10-11 12:59 ` Melissa Wen
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).