summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-11-05 16:57:48 +1100
committerStephen Rothwell <sfr@canb.auug.org.au>2013-11-05 16:57:48 +1100
commitfd47e35536a2dca6a73e9f0a2a896ae6cd14e83c (patch)
tree4b474668b0658454aadb8a57aead9e9cad036dec /lib
parentb36cfb13c13ed09ef0e213d6a11c574d42ef1bac (diff)
kfifo: kfifo_copy_{to,from}_user: fix copied bytes calculation
'copied' and 'len' are in bytes, while 'ret' is in elements, so we need to multiply 'ret' with the size of one element to get the correct result. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Stefani Seibold <stefani@seibold.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/kfifo.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/kfifo.c b/lib/kfifo.c
index 7b7f83027b7b..d79b9d222065 100644
--- a/lib/kfifo.c
+++ b/lib/kfifo.c
@@ -215,7 +215,7 @@ static unsigned long kfifo_copy_from_user(struct __kfifo *fifo,
* incrementing the fifo->in index counter
*/
smp_wmb();
- *copied = len - ret;
+ *copied = len - ret * esize;
/* return the number of elements which are not copied */
return ret;
}
@@ -275,7 +275,7 @@ static unsigned long kfifo_copy_to_user(struct __kfifo *fifo, void __user *to,
* incrementing the fifo->out index counter
*/
smp_wmb();
- *copied = len - ret;
+ *copied = len - ret * esize;
/* return the number of elements which are not copied */
return ret;
}