Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 667ecac55861 ("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>

authored by

Mario Limonciello (AMD) and committed by
Greg Kroah-Hartman
14ad4c10 c8411791

+1 -1
+1 -1
drivers/usb/typec/ucsi/ucsi.c
··· 97 97 if (!ret && cci) 98 98 ret = ucsi->ops->read_cci(ucsi, cci); 99 99 100 - if (!ret && ucsi->message_in_size > 0 && 100 + if (!ret && cci && ucsi->message_in_size > 0 && 101 101 (*cci & UCSI_CCI_COMMAND_COMPLETE)) 102 102 ret = ucsi->ops->read_message_in(ucsi, ucsi->message_in, 103 103 ucsi->message_in_size);