Re: [PATCH] usb: gadget: prevent a ternary sign expansion bug

From: Felipe Balbi
Date: Thu Apr 22 2021 - 07:04:01 EST


Dan Carpenter <dan.carpenter@xxxxxxxxxx> 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@xxxxxxxxxx>

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

Acked-by: Felipe Balbi <balbi@xxxxxxxxxx>

--
balbi

Attachment: signature.asc
Description: PGP signature