Skip to content

Commit f679f05

Browse files
committed
Fixed issue with some keyboards giving too much data
resulting in overrun of the input buffer and memory corruption causing an OOPS. We should be checking for the fact that we might get more data than we want. Thanks Naren.
1 parent e3a21fc commit f679f05

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

‎drivers/usb/host/dwc_otg/dwc_otg_hcd_ddma.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ uint8_t update_non_isoc_urb_state_ddma(dwc_otg_hcd_t * hcd,
886886
if (hc->ep_type == DWC_OTG_EP_TYPE_CONTROL) {
887887
if (qtd->control_phase == DWC_OTG_CONTROL_DATA) {
888888
urb->actual_length += n_bytes - remain;
889-
if (remain || urb->actual_length == urb->length) {
889+
if (remain || urb->actual_length >= urb->length) {
890890
/*
891891
* For Control Data stage do not set urb->status=0 to prevent
892892
* URB callback. Set it when Status phase done. See below.
@@ -905,7 +905,7 @@ uint8_t update_non_isoc_urb_state_ddma(dwc_otg_hcd_t * hcd,
905905
else {
906906
/* BULK and INTR */
907907
urb->actual_length += n_bytes - remain;
908-
if (remain || urb->actual_length == urb->length) {
908+
if (remain || urb->actual_length >= urb->length) {
909909
urb->status = 0;
910910
*xfer_done = 1;
911911
}

‎drivers/usb/host/dwc_otg/dwc_otg_hcd_intr.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ static int update_urb_state_xfer_comp(dwc_hc_t * hc,
567567
(urb->flags & URB_SEND_ZERO_PACKET) && (urb->actual_length == urb->length) &&
568568
!(urb->length % hc->max_packet)) {
569569
xfer_done = 0;
570-
} else if (short_read || urb->actual_length == urb->length) {
570+
} else if (short_read || urb->actual_length >= urb->length) {
571571
xfer_done = 1;
572572
urb->status = 0;
573573
}
@@ -1876,10 +1876,10 @@ static void handle_hc_chhltd_intr_dma(dwc_otg_hcd_t * hcd,
18761876
} else if (hcint.b.xacterr && !hcd->core_if->dma_desc_enable) {
18771877
if (out_nak_enh) {
18781878
if (hcint.b.nyet || hcint.b.nak || hcint.b.ack) {
1879-
DWC_DEBUG("XactErr with NYET/NAK/ACK\n");
1879+
DWC_DEBUGPL(DBG_HCD, "XactErr with NYET/NAK/ACK\n");
18801880
qtd->error_count = 0;
18811881
} else {
1882-
DWC_DEBUG("XactErr without NYET/NAK/ACK\n");
1882+
DWC_DEBUGPL(DBG_HCD, "XactErr without NYET/NAK/ACK\n");
18831883
}
18841884
}
18851885

‎drivers/usb/host/dwc_otg/dwc_otg_hcd_linux.c‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ static int _hub_info(dwc_otg_hcd_t * hcd, void *urb_handle, uint32_t * hub_addr,
190190
uint32_t * port_addr)
191191
{
192192
struct urb *urb = (struct urb *)urb_handle;
193+
struct usb_bus *bus;
193194
#if 1 //GRAYG - temporary
194195
if (NULL == urb_handle)
195196
DWC_ERROR("**** %s - NULL URB handle\n", __func__);//GRAYG
@@ -206,12 +207,18 @@ static int _hub_info(dwc_otg_hcd_t * hcd, void *urb_handle, uint32_t * hub_addr,
206207
*hub_addr = 0; //GRAYG
207208
// we probably shouldn't have a transaction translator if
208209
// there's no associated hub?
209-
} else
210-
*hub_addr = urb->dev->tt->hub->devnum;
210+
} else {
211+
bus = hcd_to_bus(dwc_otg_hcd_to_hcd(hcd));
212+
if (urb->dev->tt->hub == bus->root_hub)
213+
*hub_addr = 0;
214+
else
215+
*hub_addr = urb->dev->tt->hub->devnum;
216+
}
217+
*port_addr = urb->dev->tt->multi ? urb->dev->ttport : 1;
211218
} else {
212219
*hub_addr = 0;
220+
*port_addr = urb->dev->ttport;
213221
}
214-
*port_addr = urb->dev->ttport;
215222
return 0;
216223
}
217224

0 commit comments

Comments
 (0)