Skip to content

Commit 3f345e9

Browse files
Heikki Krogerusgregkh
authored andcommitted
usb: typec: ucsi: Only check the contract if there is a connection
The driver must make sure there is an actual connection before checking details about the USB Power Delivery contract. Those details are not valid unless there is a connection. This fixes NULL pointer dereference that is caused by an attempt to register bogus partner alternate mode that the firmware on some platform may report before the actual connection. Link: https://bugzilla.kernel.org/show_bug.cgi?id=215117 Fixes: 6cbe4b2 ("usb: typec: ucsi: Check the partner alt modes always if there is PD contract") Reported-by: Chris Hixon <[email protected]> Signed-off-by: Heikki Krogerus <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent e484409 commit 3f345e9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1150,7 +1150,9 @@ static int ucsi_register_port(struct ucsi *ucsi, int index)
11501150
ret = 0;
11511151
}
11521152

1153-
if (UCSI_CONSTAT_PWR_OPMODE(con->status.flags) == UCSI_CONSTAT_PWR_OPMODE_PD) {
1153+
if (con->partner &&
1154+
UCSI_CONSTAT_PWR_OPMODE(con->status.flags) ==
1155+
UCSI_CONSTAT_PWR_OPMODE_PD) {
11541156
ucsi_get_src_pdos(con);
11551157
ucsi_check_altmodes(con);
11561158
}

0 commit comments

Comments
 (0)