Skip to content

Commit b17b7fe

Browse files
RD Babieragregkh
authored andcommitted
usb: typec: class: fix typec_altmode_put_partner to put plugs
When typec_altmode_put_partner is called by a plug altmode upon release, the port altmode the plug belongs to will not remove its reference to the plug. The check to see if the altmode being released evaluates against the released altmode's partner instead of the calling altmode itself, so change adev in typec_altmode_put_partner to properly refer to the altmode being released. typec_altmode_set_partner is not run for port altmodes, so also add a check in typec_altmode_release to prevent typec_altmode_put_partner() calls on port altmode release. Fixes: 8a37d87 ("usb: typec: Bus type for alternate modes") Cc: [email protected] Signed-off-by: RD Babiera <[email protected]> Reviewed-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 73ea73a commit b17b7fe

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/usb/typec/class.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static void typec_altmode_put_partner(struct altmode *altmode)
267267
if (!partner)
268268
return;
269269

270-
adev = &partner->adev;
270+
adev = &altmode->adev;
271271

272272
if (is_typec_plug(adev->dev.parent)) {
273273
struct typec_plug *plug = to_typec_plug(adev->dev.parent);
@@ -497,7 +497,8 @@ static void typec_altmode_release(struct device *dev)
497497
{
498498
struct altmode *alt = to_altmode(to_typec_altmode(dev));
499499

500-
typec_altmode_put_partner(alt);
500+
if (!is_typec_port(dev->parent))
501+
typec_altmode_put_partner(alt);
501502

502503
altmode_id_remove(alt->adev.dev.parent, alt->id);
503504
kfree(alt);

0 commit comments

Comments
 (0)