[char-misc-next 3/3] mei: report consistently copy_from/to_user failures

From: Tomas Winkler
Date: Tue Mar 11 2014 - 08:50:36 EST


From: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>

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

Signed-off-by: Alexander Usyskin <alexander.usyskin@xxxxxxxxx>
Signed-off-by: Tomas Winkler <tomas.winkler@xxxxxxxxx>
---
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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/