[patch 39/46] USB: EHCI: fix divide-by-zero bug

From: Greg KH
Date: Mon Nov 17 2008 - 02:35:49 EST


2.6.27-stable review patch. If anyone has any objections, please let us know.

------------------

From: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

commit 372dd6e8ed924e876f3beb598721e813ad7fa323 upstream.

This patch (as1164) fixes a bug in the EHCI scheduler. The interval
value it uses is already in linear format, not logarithmically coded.
The existing code can sometimes crash the system by trying to divide
by zero.

Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
Cc: David Brownell <david-b@xxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

---
drivers/usb/host/ehci-sched.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/usb/host/ehci-sched.c
+++ b/drivers/usb/host/ehci-sched.c
@@ -918,7 +918,7 @@ iso_stream_init (
*/
stream->usecs = HS_USECS_ISO (maxp);
bandwidth = stream->usecs * 8;
- bandwidth /= 1 << (interval - 1);
+ bandwidth /= interval;

} else {
u32 addr;
@@ -951,7 +951,7 @@ iso_stream_init (
} else
stream->raw_mask = smask_out [hs_transfers - 1];
bandwidth = stream->usecs + stream->c_usecs;
- bandwidth /= 1 << (interval + 2);
+ bandwidth /= interval << 3;

/* stream->splits gets created from raw_mask later */
stream->address = cpu_to_hc32(ehci, addr);

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