usb: host: xhci: Fix bound check for interrupter number
Since max_interrupters flag includes primary interrupter as well,
update the bound check when this flag is being used for
secondary event ring clean-up/allocation.
Change-Id: I044c5a89fe17779eb847981cbf27e99b97e37d80
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c
index 99503cd..be0a89e 100644
--- a/drivers/usb/host/xhci-mem.c
+++ b/drivers/usb/host/xhci-mem.c
@@ -1905,7 +1905,7 @@
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
struct device *dev = xhci_to_hcd(xhci)->self.controller;
- if (intr_num > xhci->max_interrupters) {
+ if (intr_num >= xhci->max_interrupters) {
xhci_err(xhci, "invalid secondary interrupter num %d\n",
intr_num);
return -EINVAL;
@@ -1938,7 +1938,7 @@
struct device *dev = xhci_to_hcd(xhci)->self.controller;
/* sec event ring clean up */
- for (i = 1; i <= xhci->max_interrupters; i++)
+ for (i = 1; i < xhci->max_interrupters; i++)
xhci_sec_event_ring_cleanup(xhci_to_hcd(xhci), i);
kfree(xhci->sec_ir_set);
@@ -2567,7 +2567,7 @@
if ((xhci->xhc_state & XHCI_STATE_HALTED) || !xhci->sec_ir_set
|| !xhci->sec_event_ring || !xhci->sec_erst ||
- intr_num > xhci->max_interrupters) {
+ intr_num >= xhci->max_interrupters) {
xhci_err(xhci,
"%s:state %x ir_set %p evt_ring %p erst %p intr# %d\n",
__func__, xhci->xhc_state, xhci->sec_ir_set,
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 8bbd66b..64daa09 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -4947,8 +4947,8 @@
{
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
- if (intr_num > xhci->max_interrupters) {
- xhci_err(xhci, "intr num %d > max intrs %d\n", intr_num,
+ if (intr_num >= xhci->max_interrupters) {
+ xhci_err(xhci, "intr num %d >= max intrs %d\n", intr_num,
xhci->max_interrupters);
return 0;
}