diff options
author | Jameson Thies <[email protected]> | 2024-06-25 00:46:07 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <[email protected]> | 2024-06-27 16:09:10 +0200 |
commit | 22d96a285449ba78abeaf3e197caca46bc24f8e5 (patch) | |
tree | e72491bc4c7d7725a16dcf24a1a9a7c25c6b7e4c | |
parent | 36b1235a8ae79caacd6f2bbd7120ac7860cab734 (diff) |
usb: typec: ucsi: Only set number of plug altmodes after registration
Move the setting of the plug's number of alternate modes into the
same condition as the plug's registration to prevent dereferencing the
connector's plug pointer while it is null.
Fixes: c313a44ac9cd ("usb: typec: ucsi: Always set number of alternate modes")
Suggested-by: Jon Hunter <[email protected]>
Signed-off-by: Jameson Thies <[email protected]>
Reviewed-by: Benson Leung <[email protected]>
Reviewed-by: Heikki Krogerus <[email protected]>
Tested-by: Jon Hunter <[email protected]>
Reviewed-by: Jon Hunter <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
-rw-r--r-- | drivers/usb/typec/ucsi/ucsi.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c index 76c48d873b2a..77e46bf4a098 100644 --- a/drivers/usb/typec/ucsi/ucsi.c +++ b/drivers/usb/typec/ucsi/ucsi.c @@ -1180,13 +1180,13 @@ static int ucsi_check_cable(struct ucsi_connector *con) ret = ucsi_register_altmodes(con, UCSI_RECIPIENT_SOP_P); if (ret < 0) return ret; - } - if (con->plug_altmode[0]) { - num_plug_am = ucsi_get_num_altmode(con->plug_altmode); - typec_plug_set_num_altmodes(con->plug, num_plug_am); - } else { - typec_plug_set_num_altmodes(con->plug, 0); + if (con->plug_altmode[0]) { + num_plug_am = ucsi_get_num_altmode(con->plug_altmode); + typec_plug_set_num_altmodes(con->plug, num_plug_am); + } else { + typec_plug_set_num_altmodes(con->plug, 0); + } } return 0; |