Skip to content

Commit

Permalink
usb: typec: tcpm: Error handling for tcpm_register_partner_altmodes
Browse files Browse the repository at this point in the history
typec_partner_register_altmode returns ERR_PTR. Reset the pointer
altmode to NULL on failure.

Signed-off-by: Kyle Tso <kyletso@google.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20200714033453.4044482-3-kyletso@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Kyle Tso authored and Greg Kroah-Hartman committed Jul 21, 2020
1 parent 1401bfe commit d25d61b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/typec/tcpm/tcpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1061,9 +1061,11 @@ static void tcpm_register_partner_altmodes(struct tcpm_port *port)
for (i = 0; i < modep->altmodes; i++) {
altmode = typec_partner_register_altmode(port->partner,
&modep->altmode_desc[i]);
if (!altmode)
if (IS_ERR(altmode)) {
tcpm_log(port, "Failed to register partner SVID 0x%04x",
modep->altmode_desc[i].svid);
altmode = NULL;
}
port->partner_altmode[i] = altmode;
}
}
Expand Down

0 comments on commit d25d61b

Please sign in to comment.