usb: typec: Only attempt to link USB ports if there is fwnode
Subsystems (2)
Heikki Krogerus
maintainerPATCH 1/1 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.
---
Hi guys,
Mikhail, I got confirmation from Robert that the patch fixes the issue.
thanks,
--- drivers/usb/typec/port-mapper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/usb/typec/port-mapper.c +5 -1
@@ -56,6 +56,9 @@ int typec_link_ports(struct typec_port *con) {struct each_port_arg arg = { .port = con, .match =NULL }; +if (!has_acpi_companion (&con->dev)) +return 0 ; +bus_for_each_dev (&acpi_bus_type,NULL , &arg, typec_port_match);/*
@@ -74,5 +77,6 @@ int typec_link_ports(struct typec_port *con)void typec_unlink_ports (struct typec_port *con) { -component_master_del (&con->dev, &typec_aggregate_ops); +if (has_acpi_companion (&con->dev)) +component_master_del (&con->dev, &typec_aggregate_ops); }
Signature · 1 line
2.34.1
Heikki Krogerus
maintainerQuoted 5 lines · Heikki Krogerus
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.
Quoted 8 lines
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
_STAmethod 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.
I'll resend this togher wit the other fix.
thanks,
Quoted 39 lines
Reported-and-tested-by Robert Święcki <[email protected]>Reported-by Mikhail Gavrilov <[email protected]>Fixes 730b49aac426 ("usb: typec: port-mapper: Convert to the component framework")Signed-off-by Heikki Krogerus <[email protected]>---
Hi guys,Mikhail, I got confirmation from Robert that the patch fixes the issue.
thanks,
--- drivers/usb/typec/port-mapper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/usb/typec/port-mapper.c +5
-1@@ -56,6 +56,9 @@ int typec_link_ports(struct typec_port *con) {struct each_port_arg arg = { .port = con, .match =NULL }; +if (!has_acpi_companion (&con->dev)) +return 0 ; +bus_for_each_dev (&acpi_bus_type,NULL , &arg, typec_port_match);/* @@ -74,5 +77,6 @@ int typec_link_ports(struct typec_port *con)void typec_unlink_ports (struct typec_port *con) { -component_master_del (&con->dev, &typec_aggregate_ops); +if (has_acpi_companion (&con->dev)) +component_master_del (&con->dev, &typec_aggregate_ops); }Signature · 1 line
2.34.1
Signature · 1 line
heikki