Skip to content

Commit 61c3dae

Browse files
committed
Merge tag 'usb-4.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some small USB gadget, phy, and xhci fixes for 4.8-rc6. All of these resolve minor issues that have been reported, and all have been in linux-next with no reported issues" * tag 'usb-4.8-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: usb: chipidea: udc: fix NULL ptr dereference in isr_setup_status_phase xhci: fix null pointer dereference in stop command timeout function usb: dwc3: pci: fix build warning on !PM_SLEEP usb: gadget: prevent potenial null pointer dereference on skb->len usb: renesas_usbhs: fix clearing the {BRDY,BEMP}STS condition usb: phy: phy-generic: Check clk_prepare_enable() error usb: gadget: udc: renesas-usb3: clear VBOUT bit in DRD_CON Revert "usb: dwc3: gadget: always decrement by 1"
2 parents 98ac9a6 + 6b98174 commit 61c3dae

File tree

8 files changed

+39
-8
lines changed

8 files changed

+39
-8
lines changed

drivers/usb/chipidea/udc.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,15 @@ static int isr_setup_status_phase(struct ci_hdrc *ci)
949949
int retval;
950950
struct ci_hw_ep *hwep;
951951

952+
/*
953+
* Unexpected USB controller behavior, caused by bad signal integrity
954+
* or ground reference problems, can lead to isr_setup_status_phase
955+
* being called with ci->status equal to NULL.
956+
* If this situation occurs, you should review your USB hardware design.
957+
*/
958+
if (WARN_ON_ONCE(!ci->status))
959+
return -EPIPE;
960+
952961
hwep = (ci->ep0_dir == TX) ? ci->ep0out : ci->ep0in;
953962
ci->status->context = ci;
954963
ci->status->complete = isr_setup_status_complete;

drivers/usb/dwc3/dwc3-pci.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ static int dwc3_pci_runtime_resume(struct device *dev)
249249

250250
return pm_runtime_get(&dwc3->dev);
251251
}
252+
#endif /* CONFIG_PM */
252253

254+
#ifdef CONFIG_PM_SLEEP
253255
static int dwc3_pci_pm_dummy(struct device *dev)
254256
{
255257
/*
@@ -262,7 +264,7 @@ static int dwc3_pci_pm_dummy(struct device *dev)
262264
*/
263265
return 0;
264266
}
265-
#endif /* CONFIG_PM */
267+
#endif /* CONFIG_PM_SLEEP */
266268

267269
static struct dev_pm_ops dwc3_pci_dev_pm_ops = {
268270
SET_SYSTEM_SLEEP_PM_OPS(dwc3_pci_pm_dummy, dwc3_pci_pm_dummy)

drivers/usb/dwc3/gadget.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,9 +884,12 @@ static u32 dwc3_calc_trbs_left(struct dwc3_ep *dep)
884884
return DWC3_TRB_NUM - 1;
885885
}
886886

887-
trbs_left = dep->trb_dequeue - dep->trb_enqueue - 1;
887+
trbs_left = dep->trb_dequeue - dep->trb_enqueue;
888888
trbs_left &= (DWC3_TRB_NUM - 1);
889889

890+
if (dep->trb_dequeue < dep->trb_enqueue)
891+
trbs_left--;
892+
890893
return trbs_left;
891894
}
892895

drivers/usb/gadget/function/f_eem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ static struct sk_buff *eem_wrap(struct gether *port, struct sk_buff *skb)
342342
struct sk_buff *skb2 = NULL;
343343
struct usb_ep *in = port->in_ep;
344344
int headroom, tailroom, padlen = 0;
345-
u16 len = skb->len;
345+
u16 len;
346346

347347
if (!skb)
348348
return NULL;

drivers/usb/gadget/udc/renesas_usb3.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106

107107
/* DRD_CON */
108108
#define DRD_CON_PERI_CON BIT(24)
109+
#define DRD_CON_VBOUT BIT(0)
109110

110111
/* USB_INT_ENA_1 and USB_INT_STA_1 */
111112
#define USB_INT_1_B3_PLLWKUP BIT(31)
@@ -363,6 +364,7 @@ static void usb3_init_epc_registers(struct renesas_usb3 *usb3)
363364
{
364365
/* FIXME: How to change host / peripheral mode as well? */
365366
usb3_set_bit(usb3, DRD_CON_PERI_CON, USB3_DRD_CON);
367+
usb3_clear_bit(usb3, DRD_CON_VBOUT, USB3_DRD_CON);
366368

367369
usb3_write(usb3, ~0, USB3_USB_INT_STA_1);
368370
usb3_enable_irq_1(usb3, USB_INT_1_VBUS_CNG);

drivers/usb/host/xhci-ring.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,10 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
850850
spin_lock_irqsave(&xhci->lock, flags);
851851

852852
ep->stop_cmds_pending--;
853+
if (xhci->xhc_state & XHCI_STATE_REMOVING) {
854+
spin_unlock_irqrestore(&xhci->lock, flags);
855+
return;
856+
}
853857
if (xhci->xhc_state & XHCI_STATE_DYING) {
854858
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
855859
"Stop EP timer ran, but another timer marked "
@@ -903,7 +907,7 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg)
903907
spin_unlock_irqrestore(&xhci->lock, flags);
904908
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
905909
"Calling usb_hc_died()");
906-
usb_hc_died(xhci_to_hcd(xhci)->primary_hcd);
910+
usb_hc_died(xhci_to_hcd(xhci));
907911
xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
908912
"xHCI host controller is dead.");
909913
}

drivers/usb/phy/phy-generic.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,18 @@ static irqreturn_t nop_gpio_vbus_thread(int irq, void *data)
144144
int usb_gen_phy_init(struct usb_phy *phy)
145145
{
146146
struct usb_phy_generic *nop = dev_get_drvdata(phy->dev);
147+
int ret;
147148

148149
if (!IS_ERR(nop->vcc)) {
149150
if (regulator_enable(nop->vcc))
150151
dev_err(phy->dev, "Failed to enable power\n");
151152
}
152153

153-
if (!IS_ERR(nop->clk))
154-
clk_prepare_enable(nop->clk);
154+
if (!IS_ERR(nop->clk)) {
155+
ret = clk_prepare_enable(nop->clk);
156+
if (ret)
157+
return ret;
158+
}
155159

156160
nop_reset(nop);
157161

drivers/usb/renesas_usbhs/mod.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,16 @@ static irqreturn_t usbhs_interrupt(int irq, void *data)
282282
if (usbhs_mod_is_host(priv))
283283
usbhs_write(priv, INTSTS1, ~irq_state.intsts1 & INTSTS1_MAGIC);
284284

285-
usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);
285+
/*
286+
* The driver should not clear the xxxSTS after the line of
287+
* "call irq callback functions" because each "if" statement is
288+
* possible to call the callback function for avoiding any side effects.
289+
*/
290+
if (irq_state.intsts0 & BRDY)
291+
usbhs_write(priv, BRDYSTS, ~irq_state.brdysts);
286292
usbhs_write(priv, NRDYSTS, ~irq_state.nrdysts);
287-
usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);
293+
if (irq_state.intsts0 & BEMP)
294+
usbhs_write(priv, BEMPSTS, ~irq_state.bempsts);
288295

289296
/*
290297
* call irq callback functions

0 commit comments

Comments
 (0)