Skip to content

Commit

Permalink
kfifo: kfifo_copy_{to,from}_user: fix copied bytes calculation
Browse files Browse the repository at this point in the history
'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 <[email protected]>
Cc: Stefani Seibold <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
larsclausen authored and torvalds committed Nov 15, 2013
1 parent 07968fe commit a019e48
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/kfifo.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit a019e48

Please sign in to comment.