mei: report consistently copy_from/to_user failures
authorAlexander Usyskin <alexander.usyskin@intel.com>
Wed, 12 Mar 2014 11:19:13 +0000 (13:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Mar 2014 22:53:28 +0000 (15:53 -0700)
Consistently display error on possible copy_from/to_user failures
use dev_dbg  so it cannot be abused to flood the kernel log

Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/mei/amthif.c
drivers/misc/mei/main.c

index b75a7da1ca84c2dc849632d1de8769c3d228bb2e..2052609b167a9e37ff716c1ecbaff93e50c77d1b 100644 (file)
@@ -244,8 +244,10 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
         * the buf_idx may point beyond */
        length = min_t(size_t, length, (cb->buf_idx - *offset));
 
-       if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length))
+       if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) {
+               dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
                rets = -EFAULT;
+       }
        else {
                rets = length;
                if ((*offset + length) < cb->buf_idx) {
index 4e069b88cc46b177a65fb6ba408b58d659b2132d..bc1c39e726480d2231673145c0e1ad6bc9b84ffa 100644 (file)
@@ -280,6 +280,7 @@ copy_buffer:
        length = min_t(size_t, length, cb->buf_idx - *offset);
 
        if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) {
+               dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
                rets = -EFAULT;
                goto free;
        }
@@ -400,7 +401,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
 
        rets = copy_from_user(write_cb->request_buffer.data, ubuf, length);
        if (rets) {
-               dev_err(&dev->pdev->dev, "failed to copy data from userland\n");
+               dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n");
                rets = -EFAULT;
                goto out;
        }
@@ -565,7 +566,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, unsigned long data)
        dev_dbg(&dev->pdev->dev, "copy connect data from user\n");
        if (copy_from_user(connect_data, (char __user *)data,
                                sizeof(struct mei_connect_client_data))) {
-               dev_err(&dev->pdev->dev, "failed to copy data from userland\n");
+               dev_dbg(&dev->pdev->dev, "failed to copy data from userland\n");
                rets = -EFAULT;
                goto out;
        }
This page took 0.02618 seconds and 5 git commands to generate.