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