Skip to content

Commit 14ad4c1

Browse files
superm1gregkh
authored andcommitted
usb: typec: ucsi: Fix null pointer dereference in ucsi_sync_control_common
Add missing null check for cci parameter before dereferencing it in ucsi_sync_control_common(). The function can be called with cci=NULL from ucsi_acknowledge(), which leads to a null pointer dereference when accessing *cci in the condition check. The crash occurs because the code checks if cci is not null before calling ucsi->ops->read_cci(ucsi, cci), but then immediately dereferences cci without a null check in the following condition: (*cci & UCSI_CCI_COMMAND_COMPLETE). KASAN trace: KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:ucsi_sync_control_common+0x2ae/0x4e0 [typec_ucsi] Cc: stable <stable@kernel.org> Fixes: 667ecac ("usb: typec: ucsi: return CCI and message from sync_control callback") Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org> Link: https://patch.msgid.link/20251216122210.5457-1-superm1@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c841179 commit 14ad4c1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/usb/typec/ucsi/ucsi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci)
9797
if (!ret && cci)
9898
ret = ucsi->ops->read_cci(ucsi, cci);
9999

100-
if (!ret && ucsi->message_in_size > 0 &&
100+
if (!ret && cci && ucsi->message_in_size > 0 &&
101101
(*cci & UCSI_CCI_COMMAND_COMPLETE))
102102
ret = ucsi->ops->read_message_in(ucsi, ucsi->message_in,
103103
ucsi->message_in_size);

0 commit comments

Comments
 (0)