Skip to content

Commit a019e48

Browse files
larsclausentorvalds
authored andcommitted
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>
1 parent 07968fe commit a019e48

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎lib/kfifo.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ static unsigned long kfifo_copy_from_user(struct __kfifo *fifo,
215215
* incrementing the fifo->in index counter
216216
*/
217217
smp_wmb();
218-
*copied = len - ret;
218+
*copied = len - ret * esize;
219219
/* return the number of elements which are not copied */
220220
return ret;
221221
}
@@ -275,7 +275,7 @@ static unsigned long kfifo_copy_to_user(struct __kfifo *fifo, void __user *to,
275275
* incrementing the fifo->out index counter
276276
*/
277277
smp_wmb();
278-
*copied = len - ret;
278+
*copied = len - ret * esize;
279279
/* return the number of elements which are not copied */
280280
return ret;
281281
}

0 commit comments

Comments
 (0)