Skip to content

Commit 7817adb

Browse files
Heikki Krogerusgregkh
authored andcommitted
usb: typec: Only attempt to link USB ports if there is fwnode
The code that creates the links to the USB ports attached to a connector inside the system assumed that the ACPI nodes (fwnodes) always exist for the connectors, but it can not do that. There is no guarantee that every USB Type-C connector has ACPI device node representing it in the ACPI tables, and even if there are the nodes in the ACPI tables, the _STA method in those nodes may still return 0 (which means the device does not exist from ACPI PoW). This fixes NULL pointer dereference that happens if the nodes are missing. Fixes: 730b49a ("usb: typec: port-mapper: Convert to the component framework") Reported-and-tested-by: Robert Święcki <robert@swiecki.net> Reported-by: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com> Tested-by: Marc Zyngier <maz@kernel.org> Acked-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Link: https://lore.kernel.org/r/20220124090228.41396-2-heikki.krogerus@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5638b0d commit 7817adb

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/usb/typec/port-mapper.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ int typec_link_ports(struct typec_port *con)
5656
{
5757
struct each_port_arg arg = { .port = con, .match = NULL };
5858

59+
if (!has_acpi_companion(&con->dev))
60+
return 0;
61+
5962
bus_for_each_dev(&acpi_bus_type, NULL, &arg, typec_port_match);
6063

6164
/*
@@ -74,5 +77,6 @@ int typec_link_ports(struct typec_port *con)
7477

7578
void typec_unlink_ports(struct typec_port *con)
7679
{
77-
component_master_del(&con->dev, &typec_aggregate_ops);
80+
if (has_acpi_companion(&con->dev))
81+
component_master_del(&con->dev, &typec_aggregate_ops);
7882
}

0 commit comments

Comments
 (0)