2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2025-01-16 17:43:56 +08:00

staging: wfx: fix copy_{to,from}_user() usage

On error, copy_to_user() returns number of bytes remaining. Driver
should return -EFAULT.

Fixes: 4f8b7fabb1 ("staging: wfx: allow to send commands to chip")
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com>
Link: https://lore.kernel.org/r/20191008094232.10014-6-Jerome.Pouiller@silabs.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jérôme Pouiller 2019-10-08 09:43:00 +00:00 committed by Greg Kroah-Hartman
parent 53707c85d2
commit 51f589c82f

View File

@ -256,9 +256,8 @@ static ssize_t wfx_send_hif_msg_read(struct file *file, char __user *user_buf,
return context->ret;
// Be carefull, write() is waiting for a full message while read()
// only return a payload
ret = copy_to_user(user_buf, context->reply, count);
if (ret)
return ret;
if (copy_to_user(user_buf, context->reply, count))
return -EFAULT;
return count;
}