From: Jérôme Pouiller Date: Tue, 8 Oct 2019 09:43:00 +0000 (+0000) Subject: staging: wfx: fix copy_{to,from}_user() usage X-Git-Tag: rel_imx_5.10.35_2.0.0-somdevices.0~3384^2~306 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=51f589c82f6d4b3c9e417b39141836fb3db86093;p=linux.git staging: wfx: fix copy_{to,from}_user() usage On error, copy_to_user() returns number of bytes remaining. Driver should return -EFAULT. Fixes: 4f8b7fabb15d ("staging: wfx: allow to send commands to chip") Reported-by: kbuild test robot Reported-by: Dan Carpenter Signed-off-by: Jérôme Pouiller Link: https://lore.kernel.org/r/20191008094232.10014-6-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/wfx/debug.c b/drivers/staging/wfx/debug.c index 3261b267c385..8de16ad7c710 100644 --- a/drivers/staging/wfx/debug.c +++ b/drivers/staging/wfx/debug.c @@ -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; }