drm/amdgpu: fix EFAULT return value for debugfs ctrl parse data
Subsystems (2)
RFC PATCH 1/1 drm/amdgpu: fix EFAULT return value for debugfs ctrl parse data
amdgpu_ras_debugfs_ctrl_parse_data is reachable from a debug fs write. A write is supposed to return EFAULT when the user buffer is outside the address space. Right now it returns EINVAL.
Change the EINVAL to EFAULT.
Fixes 96ebb3073275 ("drm/amdgpu: add human readable debugfs control support (v2)")
Signed-off-by Niels Dossche <[email protected]>
---
I found this issue using static analysis to find inconsistent error handling regarding kernel APIs. Found on v5.17.4.
As I do not have the necessary hardware, I only managed to compile test this on x86_64. I put this as an RFC as I'm a bit worried about possible userspace API breakage that might rely on the EINVAL behaviour.
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -2
@@ -253,7 +253,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,memset (data,0 ,sizeof (*data));if (copy_from_user (str, buf, s)) -return -EINVAL ; +return -EFAULT ;if (sscanf (str,"disable %32s" , block_name) ==1 ) op =0 ;
@@ -308,7 +308,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,return -EINVAL ;if (copy_from_user (data, buf,sizeof (*data))) -return -EINVAL ; +return -EFAULT ; }return 0 ;
Signature · 1 line
2.35.2