Skip to content

Commit e536e0d

Browse files
committed
Merge tag 'usb-6.8-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB / Thunderbolt fixes from Greg KH: "Here are some small remaining fixes for USB and Thunderbolt drivers. Included in here are fixes for: - thunderbold NULL dereference fix - typec driver fixes - xhci driver regression fix - usb-storage divide-by-0 fix - ncm gadget driver fix All of these have been in linux-next with no reported issues" * tag 'usb-6.8-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: xhci: Fix failure to detect ring expansion need. usb: port: Don't try to peer unused USB ports based on location usb: gadget: ncm: Fix handling of zero block length packets usb: typec: altmodes/displayport: create sysfs nodes as driver's default device attribute group usb: typec: tpcm: Fix PORT_RESET behavior for self powered devices usb: typec: ucsi: fix UCSI on SM8550 & SM8650 Qualcomm devices USB: usb-storage: Prevent divide-by-0 error in isd200_ata_command thunderbolt: Fix NULL pointer dereference in tb_port_update_credits()
2 parents 49deb28 + b234c70 commit e536e0d

File tree

8 files changed

+47
-20
lines changed

8 files changed

+47
-20
lines changed

drivers/thunderbolt/switch.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,9 @@ int tb_port_update_credits(struct tb_port *port)
12491249
ret = tb_port_do_update_credits(port);
12501250
if (ret)
12511251
return ret;
1252+
1253+
if (!port->dual_link_port)
1254+
return 0;
12521255
return tb_port_do_update_credits(port->dual_link_port);
12531256
}
12541257

drivers/usb/core/port.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ static int match_location(struct usb_device *peer_hdev, void *p)
573573
struct usb_hub *peer_hub = usb_hub_to_struct_hub(peer_hdev);
574574
struct usb_device *hdev = to_usb_device(port_dev->dev.parent->parent);
575575

576-
if (!peer_hub)
576+
if (!peer_hub || port_dev->connect_type == USB_PORT_NOT_USED)
577577
return 0;
578578

579579
hcd = bus_to_hcd(hdev->bus);
@@ -584,7 +584,8 @@ static int match_location(struct usb_device *peer_hdev, void *p)
584584

585585
for (port1 = 1; port1 <= peer_hdev->maxchild; port1++) {
586586
peer = peer_hub->ports[port1 - 1];
587-
if (peer && peer->location == port_dev->location) {
587+
if (peer && peer->connect_type != USB_PORT_NOT_USED &&
588+
peer->location == port_dev->location) {
588589
link_peers_report(port_dev, peer);
589590
return 1; /* done */
590591
}

drivers/usb/gadget/function/f_ncm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ static int ncm_unwrap_ntb(struct gether *port,
13461346
if (to_process == 1 &&
13471347
(*(unsigned char *)(ntb_ptr + block_len) == 0x00)) {
13481348
to_process--;
1349-
} else if (to_process > 0) {
1349+
} else if ((to_process > 0) && (block_len != 0)) {
13501350
ntb_ptr = (unsigned char *)(ntb_ptr + block_len);
13511351
goto parse_ntb;
13521352
}

drivers/usb/host/xhci-ring.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,13 @@ static unsigned int xhci_ring_expansion_needed(struct xhci_hcd *xhci, struct xhc
326326
/* how many trbs will be queued past the enqueue segment? */
327327
trbs_past_seg = enq_used + num_trbs - (TRBS_PER_SEGMENT - 1);
328328

329-
if (trbs_past_seg <= 0)
329+
/*
330+
* Consider expanding the ring already if num_trbs fills the current
331+
* segment (i.e. trbs_past_seg == 0), not only when num_trbs goes into
332+
* the next segment. Avoids confusing full ring with special empty ring
333+
* case below
334+
*/
335+
if (trbs_past_seg < 0)
330336
return 0;
331337

332338
/* Empty ring special case, enqueue stuck on link trb while dequeue advanced */

drivers/usb/storage/isd200.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ static void isd200_dump_driveid(struct us_data *us, u16 *id)
11051105
static int isd200_get_inquiry_data( struct us_data *us )
11061106
{
11071107
struct isd200_info *info = (struct isd200_info *)us->extra;
1108-
int retStatus = ISD200_GOOD;
1108+
int retStatus;
11091109
u16 *id = info->id;
11101110

11111111
usb_stor_dbg(us, "Entering isd200_get_inquiry_data\n");
@@ -1137,6 +1137,13 @@ static int isd200_get_inquiry_data( struct us_data *us )
11371137
isd200_fix_driveid(id);
11381138
isd200_dump_driveid(us, id);
11391139

1140+
/* Prevent division by 0 in isd200_scsi_to_ata() */
1141+
if (id[ATA_ID_HEADS] == 0 || id[ATA_ID_SECTORS] == 0) {
1142+
usb_stor_dbg(us, " Invalid ATA Identify data\n");
1143+
retStatus = ISD200_ERROR;
1144+
goto Done;
1145+
}
1146+
11401147
memset(&info->InquiryData, 0, sizeof(info->InquiryData));
11411148

11421149
/* Standard IDE interface only supports disks */
@@ -1202,6 +1209,7 @@ static int isd200_get_inquiry_data( struct us_data *us )
12021209
}
12031210
}
12041211

1212+
Done:
12051213
usb_stor_dbg(us, "Leaving isd200_get_inquiry_data %08X\n", retStatus);
12061214

12071215
return(retStatus);
@@ -1481,22 +1489,27 @@ static int isd200_init_info(struct us_data *us)
14811489

14821490
static int isd200_Initialization(struct us_data *us)
14831491
{
1492+
int rc = 0;
1493+
14841494
usb_stor_dbg(us, "ISD200 Initialization...\n");
14851495

14861496
/* Initialize ISD200 info struct */
14871497

1488-
if (isd200_init_info(us) == ISD200_ERROR) {
1498+
if (isd200_init_info(us) < 0) {
14891499
usb_stor_dbg(us, "ERROR Initializing ISD200 Info struct\n");
1500+
rc = -ENOMEM;
14901501
} else {
14911502
/* Get device specific data */
14921503

1493-
if (isd200_get_inquiry_data(us) != ISD200_GOOD)
1504+
if (isd200_get_inquiry_data(us) != ISD200_GOOD) {
14941505
usb_stor_dbg(us, "ISD200 Initialization Failure\n");
1495-
else
1506+
rc = -EINVAL;
1507+
} else {
14961508
usb_stor_dbg(us, "ISD200 Initialization complete\n");
1509+
}
14971510
}
14981511

1499-
return 0;
1512+
return rc;
15001513
}
15011514

15021515

drivers/usb/typec/altmodes/displayport.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -559,24 +559,28 @@ static ssize_t hpd_show(struct device *dev, struct device_attribute *attr, char
559559
}
560560
static DEVICE_ATTR_RO(hpd);
561561

562-
static struct attribute *dp_altmode_attrs[] = {
562+
static struct attribute *displayport_attrs[] = {
563563
&dev_attr_configuration.attr,
564564
&dev_attr_pin_assignment.attr,
565565
&dev_attr_hpd.attr,
566566
NULL
567567
};
568568

569-
static const struct attribute_group dp_altmode_group = {
569+
static const struct attribute_group displayport_group = {
570570
.name = "displayport",
571-
.attrs = dp_altmode_attrs,
571+
.attrs = displayport_attrs,
572+
};
573+
574+
static const struct attribute_group *displayport_groups[] = {
575+
&displayport_group,
576+
NULL,
572577
};
573578

574579
int dp_altmode_probe(struct typec_altmode *alt)
575580
{
576581
const struct typec_altmode *port = typec_altmode_get_partner(alt);
577582
struct fwnode_handle *fwnode;
578583
struct dp_altmode *dp;
579-
int ret;
580584

581585
/* FIXME: Port can only be DFP_U. */
582586

@@ -587,10 +591,6 @@ int dp_altmode_probe(struct typec_altmode *alt)
587591
DP_CAP_PIN_ASSIGN_DFP_D(alt->vdo)))
588592
return -ENODEV;
589593

590-
ret = sysfs_create_group(&alt->dev.kobj, &dp_altmode_group);
591-
if (ret)
592-
return ret;
593-
594594
dp = devm_kzalloc(&alt->dev, sizeof(*dp), GFP_KERNEL);
595595
if (!dp)
596596
return -ENOMEM;
@@ -624,7 +624,6 @@ void dp_altmode_remove(struct typec_altmode *alt)
624624
{
625625
struct dp_altmode *dp = typec_altmode_get_drvdata(alt);
626626

627-
sysfs_remove_group(&alt->dev.kobj, &dp_altmode_group);
628627
cancel_work_sync(&dp->work);
629628

630629
if (dp->connector_fwnode) {
@@ -649,6 +648,7 @@ static struct typec_altmode_driver dp_altmode_driver = {
649648
.driver = {
650649
.name = "typec_displayport",
651650
.owner = THIS_MODULE,
651+
.dev_groups = displayport_groups,
652652
},
653653
};
654654
module_typec_altmode_driver(dp_altmode_driver);

drivers/usb/typec/tcpm/tcpm.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4873,8 +4873,11 @@ static void run_state_machine(struct tcpm_port *port)
48734873
break;
48744874
case PORT_RESET:
48754875
tcpm_reset_port(port);
4876-
tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ?
4877-
TYPEC_CC_RD : tcpm_rp_cc(port));
4876+
if (port->self_powered)
4877+
tcpm_set_cc(port, TYPEC_CC_OPEN);
4878+
else
4879+
tcpm_set_cc(port, tcpm_default_state(port) == SNK_UNATTACHED ?
4880+
TYPEC_CC_RD : tcpm_rp_cc(port));
48784881
tcpm_set_state(port, PORT_RESET_WAIT_OFF,
48794882
PD_T_ERROR_RECOVERY);
48804883
break;

drivers/usb/typec/ucsi/ucsi_glink.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ static const struct of_device_id pmic_glink_ucsi_of_quirks[] = {
301301
{ .compatible = "qcom,sc8180x-pmic-glink", .data = (void *)UCSI_NO_PARTNER_PDOS, },
302302
{ .compatible = "qcom,sc8280xp-pmic-glink", .data = (void *)UCSI_NO_PARTNER_PDOS, },
303303
{ .compatible = "qcom,sm8350-pmic-glink", .data = (void *)UCSI_NO_PARTNER_PDOS, },
304+
{ .compatible = "qcom,sm8550-pmic-glink", .data = (void *)UCSI_NO_PARTNER_PDOS, },
304305
{}
305306
};
306307

0 commit comments

Comments
 (0)