Skip to content

Commit 8e95cb3

Browse files
committed
Merge tag 'usb-4.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some USB driver fixes for 4.17-rc4. The majority of them are some USB gadget fixes that missed my last pull request. The "largest" patch in here is a fix for the old visor driver that syzbot found 6 months or so ago and I finally remembered to fix it. All of these have been in linux-next with no reported issues" * tag 'usb-4.17-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: Revert "usb: host: ehci: Use dma_pool_zalloc()" usb: typec: tps6598x: handle block reads separately with plain-I2C adapters usb: typec: tcpm: Release the role mux when exiting USB: Accept bulk endpoints with 1024-byte maxpacket xhci: Fix use-after-free in xhci_free_virt_device USB: serial: visor: handle potential invalid device configuration USB: serial: option: adding support for ublox R410M usb: musb: trace: fix NULL pointer dereference in musb_g_tx() usb: musb: host: fix potential NULL pointer dereference usb: gadget: composite Allow for larger configuration descriptors usb: dwc3: gadget: Fix list_del corruption in dwc3_ep_dequeue usb: dwc3: gadget: dwc3_gadget_del_and_unmap_request() can be static usb: dwc2: pci: Fix error return code in dwc2_pci_probe() usb: dwc2: WA for Full speed ISOC IN in DDMA mode. usb: dwc2: dwc2_vbus_supply_init: fix error check usb: gadget: f_phonet: fix pn_net_xmit()'s return type
2 parents c1c0741 + 6844dc4 commit 8e95cb3

File tree

17 files changed

+133
-58
lines changed

17 files changed

+133
-58
lines changed

drivers/usb/core/config.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ static const unsigned short full_speed_maxpacket_maxes[4] = {
191191
static const unsigned short high_speed_maxpacket_maxes[4] = {
192192
[USB_ENDPOINT_XFER_CONTROL] = 64,
193193
[USB_ENDPOINT_XFER_ISOC] = 1024,
194-
[USB_ENDPOINT_XFER_BULK] = 512,
194+
195+
/* Bulk should be 512, but some devices use 1024: we will warn below */
196+
[USB_ENDPOINT_XFER_BULK] = 1024,
195197
[USB_ENDPOINT_XFER_INT] = 1024,
196198
};
197199
static const unsigned short super_speed_maxpacket_maxes[4] = {

drivers/usb/dwc2/core.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,15 @@ struct dwc2_hsotg {
985985

986986
/* DWC OTG HW Release versions */
987987
#define DWC2_CORE_REV_2_71a 0x4f54271a
988+
#define DWC2_CORE_REV_2_72a 0x4f54272a
988989
#define DWC2_CORE_REV_2_80a 0x4f54280a
989990
#define DWC2_CORE_REV_2_90a 0x4f54290a
990991
#define DWC2_CORE_REV_2_91a 0x4f54291a
991992
#define DWC2_CORE_REV_2_92a 0x4f54292a
992993
#define DWC2_CORE_REV_2_94a 0x4f54294a
993994
#define DWC2_CORE_REV_3_00a 0x4f54300a
994995
#define DWC2_CORE_REV_3_10a 0x4f54310a
996+
#define DWC2_CORE_REV_4_00a 0x4f54400a
995997
#define DWC2_FS_IOT_REV_1_00a 0x5531100a
996998
#define DWC2_HS_IOT_REV_1_00a 0x5532100a
997999

drivers/usb/dwc2/gadget.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,6 +3928,27 @@ static int dwc2_hsotg_ep_enable(struct usb_ep *ep,
39283928
if (index && !hs_ep->isochronous)
39293929
epctrl |= DXEPCTL_SETD0PID;
39303930

3931+
/* WA for Full speed ISOC IN in DDMA mode.
3932+
* By Clear NAK status of EP, core will send ZLP
3933+
* to IN token and assert NAK interrupt relying
3934+
* on TxFIFO status only
3935+
*/
3936+
3937+
if (hsotg->gadget.speed == USB_SPEED_FULL &&
3938+
hs_ep->isochronous && dir_in) {
3939+
/* The WA applies only to core versions from 2.72a
3940+
* to 4.00a (including both). Also for FS_IOT_1.00a
3941+
* and HS_IOT_1.00a.
3942+
*/
3943+
u32 gsnpsid = dwc2_readl(hsotg->regs + GSNPSID);
3944+
3945+
if ((gsnpsid >= DWC2_CORE_REV_2_72a &&
3946+
gsnpsid <= DWC2_CORE_REV_4_00a) ||
3947+
gsnpsid == DWC2_FS_IOT_REV_1_00a ||
3948+
gsnpsid == DWC2_HS_IOT_REV_1_00a)
3949+
epctrl |= DXEPCTL_CNAK;
3950+
}
3951+
39313952
dev_dbg(hsotg->dev, "%s: write DxEPCTL=0x%08x\n",
39323953
__func__, epctrl);
39333954

drivers/usb/dwc2/hcd.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,9 +358,14 @@ static void dwc2_gusbcfg_init(struct dwc2_hsotg *hsotg)
358358

359359
static int dwc2_vbus_supply_init(struct dwc2_hsotg *hsotg)
360360
{
361+
int ret;
362+
361363
hsotg->vbus_supply = devm_regulator_get_optional(hsotg->dev, "vbus");
362-
if (IS_ERR(hsotg->vbus_supply))
363-
return 0;
364+
if (IS_ERR(hsotg->vbus_supply)) {
365+
ret = PTR_ERR(hsotg->vbus_supply);
366+
hsotg->vbus_supply = NULL;
367+
return ret == -ENODEV ? 0 : ret;
368+
}
364369

365370
return regulator_enable(hsotg->vbus_supply);
366371
}
@@ -4342,9 +4347,7 @@ static int _dwc2_hcd_start(struct usb_hcd *hcd)
43424347

43434348
spin_unlock_irqrestore(&hsotg->lock, flags);
43444349

4345-
dwc2_vbus_supply_init(hsotg);
4346-
4347-
return 0;
4350+
return dwc2_vbus_supply_init(hsotg);
43484351
}
43494352

43504353
/*

drivers/usb/dwc2/pci.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,10 @@ static int dwc2_pci_probe(struct pci_dev *pci,
141141
goto err;
142142

143143
glue = devm_kzalloc(dev, sizeof(*glue), GFP_KERNEL);
144-
if (!glue)
144+
if (!glue) {
145+
ret = -ENOMEM;
145146
goto err;
147+
}
146148

147149
ret = platform_device_add(dwc2);
148150
if (ret) {

drivers/usb/dwc3/gadget.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ static void dwc3_ep_inc_deq(struct dwc3_ep *dep)
166166
dwc3_ep_inc_trb(&dep->trb_dequeue);
167167
}
168168

169-
void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep,
169+
static void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep,
170170
struct dwc3_request *req, int status)
171171
{
172172
struct dwc3 *dwc = dep->dwc;
@@ -1424,7 +1424,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
14241424
dwc->lock);
14251425

14261426
if (!r->trb)
1427-
goto out1;
1427+
goto out0;
14281428

14291429
if (r->num_pending_sgs) {
14301430
struct dwc3_trb *trb;

drivers/usb/gadget/function/f_phonet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ static void pn_tx_complete(struct usb_ep *ep, struct usb_request *req)
221221
netif_wake_queue(dev);
222222
}
223223

224-
static int pn_net_xmit(struct sk_buff *skb, struct net_device *dev)
224+
static netdev_tx_t pn_net_xmit(struct sk_buff *skb, struct net_device *dev)
225225
{
226226
struct phonet_port *port = netdev_priv(dev);
227227
struct f_phonet *fp;

drivers/usb/host/ehci-mem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ static struct ehci_qh *ehci_qh_alloc (struct ehci_hcd *ehci, gfp_t flags)
7373
if (!qh)
7474
goto done;
7575
qh->hw = (struct ehci_qh_hw *)
76-
dma_pool_zalloc(ehci->qh_pool, flags, &dma);
76+
dma_pool_alloc(ehci->qh_pool, flags, &dma);
7777
if (!qh->hw)
7878
goto fail;
79+
memset(qh->hw, 0, sizeof *qh->hw);
7980
qh->qh_dma = dma;
8081
// INIT_LIST_HEAD (&qh->qh_list);
8182
INIT_LIST_HEAD (&qh->qtd_list);

drivers/usb/host/ehci-sched.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ itd_urb_transaction(
12871287
} else {
12881288
alloc_itd:
12891289
spin_unlock_irqrestore(&ehci->lock, flags);
1290-
itd = dma_pool_zalloc(ehci->itd_pool, mem_flags,
1290+
itd = dma_pool_alloc(ehci->itd_pool, mem_flags,
12911291
&itd_dma);
12921292
spin_lock_irqsave(&ehci->lock, flags);
12931293
if (!itd) {
@@ -1297,6 +1297,7 @@ itd_urb_transaction(
12971297
}
12981298
}
12991299

1300+
memset(itd, 0, sizeof(*itd));
13001301
itd->itd_dma = itd_dma;
13011302
itd->frame = NO_FRAME;
13021303
list_add(&itd->itd_list, &sched->td_list);
@@ -2080,7 +2081,7 @@ sitd_urb_transaction(
20802081
} else {
20812082
alloc_sitd:
20822083
spin_unlock_irqrestore(&ehci->lock, flags);
2083-
sitd = dma_pool_zalloc(ehci->sitd_pool, mem_flags,
2084+
sitd = dma_pool_alloc(ehci->sitd_pool, mem_flags,
20842085
&sitd_dma);
20852086
spin_lock_irqsave(&ehci->lock, flags);
20862087
if (!sitd) {
@@ -2090,6 +2091,7 @@ sitd_urb_transaction(
20902091
}
20912092
}
20922093

2094+
memset(sitd, 0, sizeof(*sitd));
20932095
sitd->sitd_dma = sitd_dma;
20942096
sitd->frame = NO_FRAME;
20952097
list_add(&sitd->sitd_list, &iso_sched->td_list);

drivers/usb/host/xhci.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3621,6 +3621,7 @@ static void xhci_free_dev(struct usb_hcd *hcd, struct usb_device *udev)
36213621
del_timer_sync(&virt_dev->eps[i].stop_cmd_timer);
36223622
}
36233623
xhci_debugfs_remove_slot(xhci, udev->slot_id);
3624+
virt_dev->udev = NULL;
36243625
ret = xhci_disable_slot(xhci, udev->slot_id);
36253626
if (ret)
36263627
xhci_free_virt_device(xhci, udev->slot_id);

drivers/usb/musb/musb_gadget.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,6 @@ void musb_g_tx(struct musb *musb, u8 epnum)
417417
req = next_request(musb_ep);
418418
request = &req->request;
419419

420-
trace_musb_req_tx(req);
421420
csr = musb_readw(epio, MUSB_TXCSR);
422421
musb_dbg(musb, "<== %s, txcsr %04x", musb_ep->end_point.name, csr);
423422

@@ -456,6 +455,8 @@ void musb_g_tx(struct musb *musb, u8 epnum)
456455
u8 is_dma = 0;
457456
bool short_packet = false;
458457

458+
trace_musb_req_tx(req);
459+
459460
if (dma && (csr & MUSB_TXCSR_DMAENAB)) {
460461
is_dma = 1;
461462
csr |= MUSB_TXCSR_P_WZC_BITS;

drivers/usb/musb/musb_host.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,9 @@ static void musb_bulk_nak_timeout(struct musb *musb, struct musb_hw_ep *ep,
990990
/* set tx_reinit and schedule the next qh */
991991
ep->tx_reinit = 1;
992992
}
993-
musb_start_urb(musb, is_in, next_qh);
993+
994+
if (next_qh)
995+
musb_start_urb(musb, is_in, next_qh);
994996
}
995997
}
996998

drivers/usb/serial/option.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ static void option_instat_callback(struct urb *urb);
233233
/* These Quectel products use Qualcomm's vendor ID */
234234
#define QUECTEL_PRODUCT_UC20 0x9003
235235
#define QUECTEL_PRODUCT_UC15 0x9090
236+
/* These u-blox products use Qualcomm's vendor ID */
237+
#define UBLOX_PRODUCT_R410M 0x90b2
236238
/* These Yuga products use Qualcomm's vendor ID */
237239
#define YUGA_PRODUCT_CLM920_NC5 0x9625
238240

@@ -1065,6 +1067,9 @@ static const struct usb_device_id option_ids[] = {
10651067
/* Yuga products use Qualcomm vendor ID */
10661068
{ USB_DEVICE(QUALCOMM_VENDOR_ID, YUGA_PRODUCT_CLM920_NC5),
10671069
.driver_info = RSVD(1) | RSVD(4) },
1070+
/* u-blox products using Qualcomm vendor ID */
1071+
{ USB_DEVICE(QUALCOMM_VENDOR_ID, UBLOX_PRODUCT_R410M),
1072+
.driver_info = RSVD(1) | RSVD(3) },
10681073
/* Quectel products using Quectel vendor ID */
10691074
{ USB_DEVICE(QUECTEL_VENDOR_ID, QUECTEL_PRODUCT_EC21),
10701075
.driver_info = RSVD(4) },

drivers/usb/serial/visor.c

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -335,47 +335,48 @@ static int palm_os_3_probe(struct usb_serial *serial,
335335
goto exit;
336336
}
337337

338-
if (retval == sizeof(*connection_info)) {
339-
connection_info = (struct visor_connection_info *)
340-
transfer_buffer;
341-
342-
num_ports = le16_to_cpu(connection_info->num_ports);
343-
for (i = 0; i < num_ports; ++i) {
344-
switch (
345-
connection_info->connections[i].port_function_id) {
346-
case VISOR_FUNCTION_GENERIC:
347-
string = "Generic";
348-
break;
349-
case VISOR_FUNCTION_DEBUGGER:
350-
string = "Debugger";
351-
break;
352-
case VISOR_FUNCTION_HOTSYNC:
353-
string = "HotSync";
354-
break;
355-
case VISOR_FUNCTION_CONSOLE:
356-
string = "Console";
357-
break;
358-
case VISOR_FUNCTION_REMOTE_FILE_SYS:
359-
string = "Remote File System";
360-
break;
361-
default:
362-
string = "unknown";
363-
break;
364-
}
365-
dev_info(dev, "%s: port %d, is for %s use\n",
366-
serial->type->description,
367-
connection_info->connections[i].port, string);
368-
}
338+
if (retval != sizeof(*connection_info)) {
339+
dev_err(dev, "Invalid connection information received from device\n");
340+
retval = -ENODEV;
341+
goto exit;
369342
}
370-
/*
371-
* Handle devices that report invalid stuff here.
372-
*/
343+
344+
connection_info = (struct visor_connection_info *)transfer_buffer;
345+
346+
num_ports = le16_to_cpu(connection_info->num_ports);
347+
348+
/* Handle devices that report invalid stuff here. */
373349
if (num_ports == 0 || num_ports > 2) {
374350
dev_warn(dev, "%s: No valid connect info available\n",
375351
serial->type->description);
376352
num_ports = 2;
377353
}
378354

355+
for (i = 0; i < num_ports; ++i) {
356+
switch (connection_info->connections[i].port_function_id) {
357+
case VISOR_FUNCTION_GENERIC:
358+
string = "Generic";
359+
break;
360+
case VISOR_FUNCTION_DEBUGGER:
361+
string = "Debugger";
362+
break;
363+
case VISOR_FUNCTION_HOTSYNC:
364+
string = "HotSync";
365+
break;
366+
case VISOR_FUNCTION_CONSOLE:
367+
string = "Console";
368+
break;
369+
case VISOR_FUNCTION_REMOTE_FILE_SYS:
370+
string = "Remote File System";
371+
break;
372+
default:
373+
string = "unknown";
374+
break;
375+
}
376+
dev_info(dev, "%s: port %d, is for %s use\n",
377+
serial->type->description,
378+
connection_info->connections[i].port, string);
379+
}
379380
dev_info(dev, "%s: Number of ports: %d\n", serial->type->description,
380381
num_ports);
381382

drivers/usb/typec/tcpm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3725,6 +3725,7 @@ void tcpm_unregister_port(struct tcpm_port *port)
37253725
for (i = 0; i < ARRAY_SIZE(port->port_altmode); i++)
37263726
typec_unregister_altmode(port->port_altmode[i]);
37273727
typec_unregister_port(port->typec_port);
3728+
usb_role_switch_put(port->role_sw);
37283729
tcpm_debugfs_exit(port);
37293730
destroy_workqueue(port->wq);
37303731
}

0 commit comments

Comments
 (0)