Commit b8badd50 authored by Dan Carpenter's avatar Dan Carpenter Committed by Alex Deucher

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: c65b0805 ("drm/amdgpu: RAS EEPROM table is now in debugfs")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarLuben Tuikov <luben.tuikov@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1d864f10
...@@ -821,7 +821,7 @@ static ssize_t amdgpu_ras_debugfs_table_read(struct file *f, char __user *buf, ...@@ -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 *ras = amdgpu_ras_get_context(adev);
struct amdgpu_ras_eeprom_control *control = &ras->eeprom_control; struct amdgpu_ras_eeprom_control *control = &ras->eeprom_control;
const size_t orig_size = size; const size_t orig_size = size;
int res = -EINVAL; int res = -EFAULT;
size_t data_len; size_t data_len;
mutex_lock(&control->ras_tbl_mutex); mutex_lock(&control->ras_tbl_mutex);
...@@ -912,8 +912,10 @@ static ssize_t amdgpu_ras_debugfs_table_read(struct file *f, char __user *buf, ...@@ -912,8 +912,10 @@ static ssize_t amdgpu_ras_debugfs_table_read(struct file *f, char __user *buf,
record.retired_page); record.retired_page);
data_len = min_t(size_t, rec_hdr_fmt_size - r, size); data_len = min_t(size_t, rec_hdr_fmt_size - r, size);
if (copy_to_user(buf, &data[r], data_len)) if (copy_to_user(buf, &data[r], data_len)) {
return -EINVAL; res = -EFAULT;
goto Out;
}
buf += data_len; buf += data_len;
size -= data_len; size -= data_len;
*pos += data_len; *pos += data_len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment