OSDN Git Service

drm/amdgpu: return -EFAULT if copy_to_user() fails
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 3 Jul 2021 09:46:20 +0000 (12:46 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 8 Jul 2021 21:47:28 +0000 (17:47 -0400)
If copy_to_user() fails then this should return -EFAULT instead of
-EINVAL.

Fixes: c65b0805e77919 ("drm/amdgpu: RAS EEPROM table is now in debugfs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Luben Tuikov <luben.tuikov@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c

index 3e33e85..d2e5b25 100644 (file)
@@ -771,7 +771,7 @@ amdgpu_ras_debugfs_eeprom_size_read(struct file *f, char __user *buf,
        res = min_t(size_t, res, size);
 
        if (copy_to_user(buf, &data[*pos], res))
-               return -EINVAL;
+               return -EFAULT;
 
        *pos += res;
 
@@ -950,7 +950,7 @@ amdgpu_ras_debugfs_eeprom_table_read(struct file *f, char __user *buf,
                res = min_t(size_t, res, size);
 
                if (copy_to_user(buf, &data[*pos], res))
-                       return -EINVAL;
+                       return -EFAULT;
 
                *pos += res;