* [PATCH] kfifo: kfifo_copy_{to,from}_user: Fix copied bytes calculation
@ 2013-09-16 8:53 Lars-Peter Clausen
0 siblings, 0 replies; only message in thread
From: Lars-Peter Clausen @ 2013-09-16 8:53 UTC (permalink / raw)
To: Andrew Morton, Stefani Seibold; +Cc: linux-kernel, Lars-Peter Clausen
'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>
---
lib/kfifo.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/kfifo.c b/lib/kfifo.c
index 7b7f830..d79b9d2 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;
}
--
1.8.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-09-16 8:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-16 8:53 [PATCH] kfifo: kfifo_copy_{to,from}_user: Fix copied bytes calculation Lars-Peter Clausen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®