ucsi driver fixes for usb-linus
Subsystems (3)
Heikki Krogerus
maintainercover ucsi driver fixes for usb-linus
Heikki Krogerus (2):
usb: typec: ucsi: displayport: Fix NULL pointer dereference
usb: typec: ucsi: displayport: Fix a potential race during
registration
drivers/usb/typec/ucsi/displayport.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
Heikki Krogerus
maintainerPATCH 1/2 usb: typec: ucsi: displayport: Fix NULL pointer dereference
If the registration of the DisplayPort was not successful, or if the port does not support DisplayPort alt mode in the first place, the function ucsi_displayport_remove_partner() will fail with NULL pointer dereference when it attempts to access the driver data.
Adding a check to the function to make sure there really is driver data for the device before modifying it.
--- drivers/usb/typec/ucsi/displayport.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/usb/typec/ucsi/displayport.c +3 -0
@@ -271,6 +271,9 @@ void ucsi_displayport_remove_partner(struct typec_altmode *alt)return ; dp =typec_altmode_get_drvdata (alt); +if (!dp) +return ; + dp->data.conf =0 ; dp->data.status =0 ; dp->initialized = false;
Signature · 1 line
2.25.1
Heikki Krogerus
maintainerPATCH 2/2 usb: typec: ucsi: displayport: Fix a potential race during registration
In reply to Heikki KrogerusLocking the connector in ucsi_register_displayport() to make sure that nothing can access the displayport alternate mode before the function has finished and the alternate mode is actually ready.
--- drivers/usb/typec/ucsi/displayport.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/usb/typec/ucsi/displayport.c +8 -1
@@ -288,6 +288,8 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con,struct typec_altmode *alt;struct ucsi_dp *dp; +mutex_lock (&con->lock); +/* We can't rely on the firmware with the capabilities. */ desc->vdo |=DP_CAP_DP_SIGNALING |DP_CAP_RECEPTACLE ;
@@ -296,12 +298,15 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con, desc->vdo |= all_assignments <<16 ; alt =typec_port_register_altmode (con->port, desc); -if (IS_ERR (alt)) +if (IS_ERR (alt)) { +mutex_unlock (&con->lock);return alt; + } dp =devm_kzalloc (&alt->dev,sizeof (*dp),GFP_KERNEL );if (!dp) {typec_unregister_altmode (alt); +mutex_unlock (&con->lock);return ERR_PTR (-ENOMEM ); }
@@ -314,5 +319,7 @@ struct typec_altmode *ucsi_register_displayport(struct ucsi_connector *con, alt->ops = &ucsi_displayport_ops;typec_altmode_set_drvdata (alt, dp); +mutex_unlock (&con->lock); +return alt; }
Signature · 1 line
2.25.1