lkml.org 
[lkml]   [2021]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] soc: aspeed: fix a ternary sign expansion bug
On Thu, Apr 22, 2021 at 12:11:44PM +0300, Dan Carpenter wrote:
> The intent here was to return negative error codes but it actually
> returns positive values. The problem is that type promotion with
> ternary operations is quite complicated.
>
> "ret" is an int. "copied" is a u32. And the snoop_file_read() function
> returns long. What happens is that "ret" is cast to u32 and becomes
> positive then it's cast to long and it's still positive.
>
> Fix this by removing the ternary so that "ret" is type promoted directly
> to long.

Hmm... Let's grep for kfifo_to_user() - smells like a possible recurring bug...
Yup -

samples/kfifo/bytestream-example.c:138: ret = kfifo_to_user(&test, buf, count, &copied);
samples/kfifo/inttype-example.c:131: ret = kfifo_to_user(&test, buf, count, &copied);
samples/kfifo/record-example.c:145: ret = kfifo_to_user(&test, buf, count, &copied);

All three are exactly like that one.

\
 
 \ /
  Last update: 2021-04-22 11:27    [W:0.105 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site