lkml.org 
[lkml]   [2021]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] usb: gadget: prevent a ternary sign expansion bug
Date
Dan Carpenter <dan.carpenter@oracle.com> writes:

> The problem is that "req->actual" is a u32, "req->status" is an int, and
> iocb->ki_complete() takes a long. We would expect that a negative error
> code in "req->status" would translate to a negative long value.
>
> But what actually happens is that because "req->actual" is a u32, the
> error codes is type promoted to a high positive value and then remains
> a positive value when it is cast to long. (No sign expansion).
>
> We can fix this by casting "req->status" to long.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

I'm just going to assume your type promotion rank is correct :-)

Acked-by: Felipe Balbi <balbi@kernel.org>

--
balbi
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2021-04-22 13:04    [W:0.023 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site