Commit ec74765d authored by Dan Carpenter's avatar Dan Carpenter Committed by Rafael J. Wysocki

ACPI / debugger: copy_to_user doesn't return errors

The copy_to/from_user() functions don't return error codes, they return
the number of bytes remaining.  We had intended to return -EFUALT here.
We actually have already checked access_ok() in an earlier function so
I don't think these functions will fail but let's fix it anyway.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 436db5ce
...@@ -592,9 +592,10 @@ static int acpi_aml_read_user(char __user *buf, int len) ...@@ -592,9 +592,10 @@ static int acpi_aml_read_user(char __user *buf, int len)
smp_rmb(); smp_rmb();
p = &crc->buf[crc->tail]; p = &crc->buf[crc->tail];
n = min(len, circ_count_to_end(crc)); n = min(len, circ_count_to_end(crc));
ret = copy_to_user(buf, p, n); if (copy_to_user(buf, p, n)) {
if (IS_ERR_VALUE(ret)) ret = -EFAULT;
goto out; goto out;
}
/* sync tail after removing logs */ /* sync tail after removing logs */
smp_mb(); smp_mb();
crc->tail = (crc->tail + n) & (ACPI_AML_BUF_SIZE - 1); crc->tail = (crc->tail + n) & (ACPI_AML_BUF_SIZE - 1);
...@@ -661,9 +662,10 @@ static int acpi_aml_write_user(const char __user *buf, int len) ...@@ -661,9 +662,10 @@ static int acpi_aml_write_user(const char __user *buf, int len)
smp_mb(); smp_mb();
p = &crc->buf[crc->head]; p = &crc->buf[crc->head];
n = min(len, circ_space_to_end(crc)); n = min(len, circ_space_to_end(crc));
ret = copy_from_user(p, buf, n); if (copy_from_user(p, buf, n)) {
if (IS_ERR_VALUE(ret)) ret = -EFAULT;
goto out; goto out;
}
/* sync head after inserting cmds */ /* sync head after inserting cmds */
smp_wmb(); smp_wmb();
crc->head = (crc->head + n) & (ACPI_AML_BUF_SIZE - 1); crc->head = (crc->head + n) & (ACPI_AML_BUF_SIZE - 1);
......
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