mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
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>
This commit is contained in:
parent
07968fe4ac
commit
a019e48cfb
1 changed files with 2 additions and 2 deletions
|
@ -215,7 +215,7 @@ static unsigned long kfifo_copy_from_user(struct __kfifo *fifo,
|
||||||
* incrementing the fifo->in index counter
|
* incrementing the fifo->in index counter
|
||||||
*/
|
*/
|
||||||
smp_wmb();
|
smp_wmb();
|
||||||
*copied = len - ret;
|
*copied = len - ret * esize;
|
||||||
/* return the number of elements which are not copied */
|
/* return the number of elements which are not copied */
|
||||||
return ret;
|
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
|
* incrementing the fifo->out index counter
|
||||||
*/
|
*/
|
||||||
smp_wmb();
|
smp_wmb();
|
||||||
*copied = len - ret;
|
*copied = len - ret * esize;
|
||||||
/* return the number of elements which are not copied */
|
/* return the number of elements which are not copied */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue