diff options
author | Hemant Kumar <hemantk@codeaurora.org> | 2017-02-07 11:50:13 -0800 |
---|---|---|
committer | Hemant Kumar <hemantk@codeaurora.org> | 2017-02-09 11:46:58 -0800 |
commit | 4def2670674389b28981cc6999062b2b2e93ba6b (patch) | |
tree | 7b6bf02ae64eda3a459156e3b352c30f7649af4c | |
parent | 2aa89ab3ff59a788321bc6af782d639cfc8dab1f (diff) |
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>
-rw-r--r-- | drivers/usb/host/xhci-mem.c | 6 | ||||
-rw-r--r-- | drivers/usb/host/xhci.c | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 2b4f3a02f7e8..098df6ced1c3 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -1870,7 +1870,7 @@ int xhci_sec_event_ring_cleanup(struct usb_hcd *hcd, unsigned intr_num) 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; @@ -1903,7 +1903,7 @@ void xhci_event_ring_cleanup(struct xhci_hcd *xhci) 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); @@ -2552,7 +2552,7 @@ int xhci_sec_event_ring_setup(struct usb_hcd *hcd, unsigned intr_num) 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 %pK evt_ring %pK erst %pK 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 6e2c2f2bcce2..3e49ca73c2c7 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -4984,8 +4984,8 @@ dma_addr_t xhci_get_sec_event_ring_dma_addr(struct usb_hcd *hcd, { 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; } |