RE: [PATCH] usb: host: add cast to avoid potential integer overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Gustavo A. R. Silva
> Sent: 17 February 2017 00:17
> The type of variable 'sel' is unsigned int. Such variable is being used
> multiple times in a context that expects an expression of type unsigned
> long long. So, to avoid any potential integer overflow, a cast to type
> unsigned long long is added.
...
> -		timeout_ns = udev->u1_params.sel * 3;
> +		timeout_ns = (unsigned long long)udev->u1_params.sel * 3;
...

It is probably better to just change the constant to 3ull.
However I'd be tempted to look more closely at the valid values
for 'timeout_ns'.
It seems unlikely that that the timeout (in sel) will be near
enough to 4 seconds that multiplying by a small integer will
take the value over 4 seconds without requiring larger input
values be supported.

timeout_ns might even be being used in places where the value
has to be smaller than 1 second!

	David

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux