Merge branch 'pm-tools'
[cascardo/linux.git] / drivers / acpi / acpi_dbg.c
index fa18bd0..15e4604 100644 (file)
@@ -514,7 +514,7 @@ static int acpi_aml_open(struct inode *inode, struct file *file)
                if (ACPI_FAILURE(status)) {
                        pr_err("Failed to initialize debugger.\n");
                        ret = -EINVAL;
-                       goto err_lock;
+                       goto err_exit;
                }
                pr_debug("Debugger thread initialized.\n");
 
@@ -531,6 +531,7 @@ err_lock:
                        acpi_aml_active_reader = NULL;
        }
        mutex_unlock(&acpi_aml_io.lock);
+err_exit:
        return ret;
 }
 
@@ -592,9 +593,10 @@ static int acpi_aml_read_user(char __user *buf, int len)
        smp_rmb();
        p = &crc->buf[crc->tail];
        n = min(len, circ_count_to_end(crc));
-       ret = copy_to_user(buf, p, n);
-       if (IS_ERR_VALUE(ret))
+       if (copy_to_user(buf, p, n)) {
+               ret = -EFAULT;
                goto out;
+       }
        /* sync tail after removing logs */
        smp_mb();
        crc->tail = (crc->tail + n) & (ACPI_AML_BUF_SIZE - 1);
@@ -610,8 +612,6 @@ static ssize_t acpi_aml_read(struct file *file, char __user *buf,
        int ret = 0;
        int size = 0;
 
-       if (!buf || count < 0)
-               return -EINVAL;
        if (!count)
                return 0;
        if (!access_ok(VERIFY_WRITE, buf, count))
@@ -663,9 +663,10 @@ static int acpi_aml_write_user(const char __user *buf, int len)
        smp_mb();
        p = &crc->buf[crc->head];
        n = min(len, circ_space_to_end(crc));
-       ret = copy_from_user(p, buf, n);
-       if (IS_ERR_VALUE(ret))
+       if (copy_from_user(p, buf, n)) {
+               ret = -EFAULT;
                goto out;
+       }
        /* sync head after inserting cmds */
        smp_wmb();
        crc->head = (crc->head + n) & (ACPI_AML_BUF_SIZE - 1);
@@ -681,8 +682,6 @@ static ssize_t acpi_aml_write(struct file *file, const char __user *buf,
        int ret = 0;
        int size = 0;
 
-       if (!buf || count < 0)
-               return -EINVAL;
        if (!count)
                return 0;
        if (!access_ok(VERIFY_READ, buf, count))