Skip to content

Commit f82060d

Browse files
Heikki Krogerusgregkh
authored andcommitted
usb: typec: ucsi: Don't attempt to resume the ports before they exist
This will fix null pointer dereference that was caused by the driver attempting to resume ports that were not yet registered. Fixes: e0dced9 ("usb: typec: ucsi: Resume in separate work") Cc: <[email protected]> Link: https://bugzilla.kernel.org/show_bug.cgi?id=216697 Signed-off-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 30d09b3 commit f82060d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,9 @@ static int ucsi_init(struct ucsi *ucsi)
12691269
con->port = NULL;
12701270
}
12711271

1272+
kfree(ucsi->connector);
1273+
ucsi->connector = NULL;
1274+
12721275
err_reset:
12731276
memset(&ucsi->cap, 0, sizeof(ucsi->cap));
12741277
ucsi_reset_ppm(ucsi);
@@ -1300,7 +1303,8 @@ static void ucsi_resume_work(struct work_struct *work)
13001303

13011304
int ucsi_resume(struct ucsi *ucsi)
13021305
{
1303-
queue_work(system_long_wq, &ucsi->resume_work);
1306+
if (ucsi->connector)
1307+
queue_work(system_long_wq, &ucsi->resume_work);
13041308
return 0;
13051309
}
13061310
EXPORT_SYMBOL_GPL(ucsi_resume);
@@ -1420,6 +1424,9 @@ void ucsi_unregister(struct ucsi *ucsi)
14201424
/* Disable notifications */
14211425
ucsi->ops->async_write(ucsi, UCSI_CONTROL, &cmd, sizeof(cmd));
14221426

1427+
if (!ucsi->connector)
1428+
return;
1429+
14231430
for (i = 0; i < ucsi->cap.num_connectors; i++) {
14241431
cancel_work_sync(&ucsi->connector[i].work);
14251432
ucsi_unregister_partner(&ucsi->connector[i]);

0 commit comments

Comments
 (0)