drm/amdgpu: unlock on error in amdgpu_ras_debugfs_table_read()
This error path needs to unlock before returning. While we're at it,
the correct error code from copy_to_user() failure is -EFAULT, not
-EINVAL.
Fixes: c65b0805e7
("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>
This commit is contained in:
parent
1d864f1088
commit
b8badd507a
|
@ -821,7 +821,7 @@ static ssize_t amdgpu_ras_debugfs_table_read(struct file *f, char __user *buf,
|
|||
struct amdgpu_ras *ras = amdgpu_ras_get_context(adev);
|
||||
struct amdgpu_ras_eeprom_control *control = &ras->eeprom_control;
|
||||
const size_t orig_size = size;
|
||||
int res = -EINVAL;
|
||||
int res = -EFAULT;
|
||||
size_t data_len;
|
||||
|
||||
mutex_lock(&control->ras_tbl_mutex);
|
||||
|
@ -912,8 +912,10 @@ static ssize_t amdgpu_ras_debugfs_table_read(struct file *f, char __user *buf,
|
|||
record.retired_page);
|
||||
|
||||
data_len = min_t(size_t, rec_hdr_fmt_size - r, size);
|
||||
if (copy_to_user(buf, &data[r], data_len))
|
||||
return -EINVAL;
|
||||
if (copy_to_user(buf, &data[r], data_len)) {
|
||||
res = -EFAULT;
|
||||
goto Out;
|
||||
}
|
||||
buf += data_len;
|
||||
size -= data_len;
|
||||
*pos += data_len;
|
||||
|
|
Loading…
Reference in New Issue