aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-11-14 17:32:16 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-14 19:32:23 -0500
commita019e48cfbfb358786326db3dbc1c565b8f14a56 (patch)
treeecb17f9f9dde58a8da4b340129efabdece82dcc0 /lib
parent07968fe4acec6d49e39520ef407ea7f6874b7c2e (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> Signed-off-by: Linus Torvalds <torvalds@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,
215 * incrementing the fifo->in index counter 215 * incrementing the fifo->in index counter
216 */ 216 */
217 smp_wmb(); 217 smp_wmb();
218 *copied = len - ret; 218 *copied = len - ret * esize;
219 /* return the number of elements which are not copied */ 219 /* return the number of elements which are not copied */
220 return ret; 220 return ret;
221} 221}
@@ -275,7 +275,7 @@ static unsigned long kfifo_copy_to_user(struct __kfifo *fifo, void __user *to,
275 * incrementing the fifo->out index counter 275 * incrementing the fifo->out index counter
276 */ 276 */
277 smp_wmb(); 277 smp_wmb();
278 *copied = len - ret; 278 *copied = len - ret * esize;
279 /* return the number of elements which are not copied */ 279 /* return the number of elements which are not copied */
280 return ret; 280 return ret;
281} 281}