Skip to content

Commit 66e1a88

Browse files
Andrei Kuchynskigregkh
authored andcommitted
usb: typec: class: Invalidate USB device pointers on partner unregistration
To avoid using invalid USB device pointers after a Type-C partner disconnects, this patch clears the pointers upon partner unregistration. This ensures a clean state for future connections. Cc: [email protected] Fixes: 59de2a5 ("usb: typec: Link enumerated USB devices with Type-C partner") Signed-off-by: Andrei Kuchynski <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Reviewed-by: Benson Leung <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ec27386 commit 66e1a88

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/usb/typec/class.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,10 +1086,14 @@ void typec_unregister_partner(struct typec_partner *partner)
10861086
port = to_typec_port(partner->dev.parent);
10871087

10881088
mutex_lock(&port->partner_link_lock);
1089-
if (port->usb2_dev)
1089+
if (port->usb2_dev) {
10901090
typec_partner_unlink_device(partner, port->usb2_dev);
1091-
if (port->usb3_dev)
1091+
port->usb2_dev = NULL;
1092+
}
1093+
if (port->usb3_dev) {
10921094
typec_partner_unlink_device(partner, port->usb3_dev);
1095+
port->usb3_dev = NULL;
1096+
}
10931097

10941098
device_unregister(&partner->dev);
10951099
mutex_unlock(&port->partner_link_lock);

0 commit comments

Comments
 (0)