Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1584587
| From | David Laight <David.Laight@ACULAB.COM> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH] usb: host: add cast to avoid potential integer overflow |
| Date | 2017-02-20 13:50 +0100 |
| Message-ID | <tcVzI-4Iy-17@gated-at.bofh.it> (permalink) |
| References | <tbErg-5k2-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[PATCH] usb: host: add cast to avoid potential integer overflow "Gustavo A. R. Silva" <garsilva@embeddedor.com> - 2017-02-17 01:20 +0100 RE: [PATCH] usb: host: add cast to avoid potential integer overflow David Laight <David.Laight@ACULAB.COM> - 2017-02-20 13:50 +0100
csiph-web