xpp_usb: Fix potential corruption on clock rewind
The xpp modules use time differences for various statistics. In one case xpp_usb creates a histogram of the time it took the system to send USB packets (URBs). The time difference is used (after adjustments) as an index to that array. However if the clock happens to go back at that exact point in time, we get to write to an arbitrary negative index in this array. Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
This commit is contained in:
parent
4b242c3f84
commit
ffdfdfb66b
@ -890,6 +890,8 @@ static void xpp_send_callback(USB_PASS_CB(urb))
|
|||||||
do_gettimeofday(&now);
|
do_gettimeofday(&now);
|
||||||
xusb->last_tx = xframe->tv_submitted;
|
xusb->last_tx = xframe->tv_submitted;
|
||||||
usec = usec_diff(&now, &xframe->tv_submitted);
|
usec = usec_diff(&now, &xframe->tv_submitted);
|
||||||
|
if (usec < 0)
|
||||||
|
usec = 0; /* System clock jumped */
|
||||||
if (usec > xusb->max_tx_delay)
|
if (usec > xusb->max_tx_delay)
|
||||||
xusb->max_tx_delay = usec;
|
xusb->max_tx_delay = usec;
|
||||||
i = usec / USEC_BUCKET;
|
i = usec / USEC_BUCKET;
|
||||||
|
Loading…
Reference in New Issue
Block a user