From: Alexander Usyskin <alexander.usys...@intel.com>

Consistently display error on possible copy_from/to_user failures
and replace dev_dbg with dev_err

Signed-off-by: Alexander Usyskin <alexander.usys...@intel.com>
Signed-off-by: Tomas Winkler <tomas.wink...@intel.com>
---
 drivers/misc/mei/amthif.c | 4 +++-
 drivers/misc/mei/main.c   | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/mei/amthif.c b/drivers/misc/mei/amthif.c
index b75a7da..2e7d914 100644
--- a/drivers/misc/mei/amthif.c
+++ b/drivers/misc/mei/amthif.c
@@ -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_err(&dev->pdev->dev, "failed to copy data to userland\n");
                rets = -EFAULT;
+       }
        else {
                rets = length;
                if ((*offset + length) < cb->buf_idx) {
diff --git a/drivers/misc/mei/main.c b/drivers/misc/mei/main.c
index 4e069b8..819aa8b 100644
--- a/drivers/misc/mei/main.c
+++ b/drivers/misc/mei/main.c
@@ -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_err(&dev->pdev->dev, "failed to copy data to userland\n");
                rets = -EFAULT;
                goto free;
        }
@@ -579,7 +580,7 @@ static long mei_ioctl(struct file *file, unsigned int cmd, 
unsigned long data)
        dev_dbg(&dev->pdev->dev, "copy connect data to user\n");
        if (copy_to_user((char __user *)data, connect_data,
                                sizeof(struct mei_connect_client_data))) {
-               dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
+               dev_err(&dev->pdev->dev, "failed to copy data to userland\n");
                rets = -EFAULT;
                goto out;
        }
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to