usb-ohci: td.cbp incorrectly updated near page end
authorAndriy Gapon <avg@FreeBSD.org>
Thu, 22 Dec 2011 09:34:30 +0000 (11:34 +0200)
committerJustin M. Forbes <jforbes@redhat.com>
Tue, 10 Jan 2012 15:45:48 +0000 (09:45 -0600)
commit3dc42254ec97e2feca16a7d02eafffcc8e0a0a34
tree238ed4fe2d550406dd999ff22d879500ce0537e3
parent85dc360b422ebe685bcb5e6801d4c91922fdefa5
usb-ohci: td.cbp incorrectly updated near page end

The current code that updates the cbp value after a transfer looks like this:
td.cbp += ret;
if ((td.cbp & 0xfff) + ret > 0xfff) {
<handle page overflow>
because the 'ret' value is effectively added twice the check may fire too early
when the overflow hasn't happened yet.

Below is one of the possible changes that correct the behavior:

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/usb-ohci.c