Skip to content

Commit

Permalink
mei: report consistently copy_from/to_user failures
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexander Usyskin authored and Greg Kroah-Hartman committed Mar 17, 2014
1 parent 80260f2 commit dbac474
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion drivers/misc/mei/amthif.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 3 additions & 2 deletions drivers/misc/mei/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ static ssize_t mei_read(struct file *file, char __user *ubuf,
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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit dbac474

Please sign in to comment.