usb: typec: ucsi: Fix null pointer dereference in ucsi_sync_control_common
Subsystems (2)
PATCH 1/1 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]
--- drivers/usb/typec/ucsi/ucsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/typec/ucsi/ucsi.c +1 -1
@@ -97,7 +97,7 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci)if (!ret && cci) ret = ucsi->ops->read_cci (ucsi, cci); -if (!ret && ucsi->message_in_size >0 && +if (!ret && cci && ucsi->message_in_size >0 && (*cci &UCSI_CCI_COMMAND_COMPLETE )) ret = ucsi->ops->read_message_in (ucsi, ucsi->message_in, ucsi->message_in_size);
Signature · 1 line
2.43.0
Greg KH
maintainerQuoted 11 lines · Mario Limonciello (AMD)
Add missing null check for cci parameter before dereferencing it in
ucsi_sync_control_common(). The function can be called with cci=NULL fromucsi_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:
Quoted 8 lines
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:ucsi_sync_control_common+0x2ae/0x4e0 [typec_ucsi]Fixes 667ecac55861 ("usb: typec: ucsi: return CCI and message from sync_control callback")Signed-off-by Mario Limonciello (AMD) <[email protected]>--- drivers/usb/typec/ucsi/ucsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.
You are receiving this message because of the following common error(s) as indicated below:
- You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this.
If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.
thanks,
greg k-h's patch email bot
Sun, Dec 14, 2025 at 12:36:41PM -0600, Mario Limonciello (AMD) kirjoitti:
Quoted 10 lines
Add missing null check for cci parameter before dereferencing it in
ucsi_sync_control_common(). The function can be called with cci=NULL fromucsi_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).
Quoted 6 lines
KASAN trace:
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] RIP: 0010:ucsi_sync_control_common+0x2ae/0x4e0 [typec_ucsi]Fixes 667ecac55861 ("usb: typec: ucsi: return CCI and message from sync_control callback")Signed-off-by Mario Limonciello (AMD) <[email protected]>
I guess you need the CC stable tag.
Quoted 19 lines
--- drivers/usb/typec/ucsi/ucsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/typec/ucsi/ucsi.c +1
-1@@ -97,7 +97,7 @@ int ucsi_sync_control_common(struct ucsi *ucsi, u64 command, u32 *cci)if (!ret && cci) ret = ucsi->ops->read_cci (ucsi, cci); -if (!ret && ucsi->message_in_size >0 && +if (!ret && cci && ucsi->message_in_size >0 && (*cci &UCSI_CCI_COMMAND_COMPLETE )) ret = ucsi->ops->read_message_in (ucsi, ucsi->message_in, ucsi->message_in_size);Signature · 1 line
2.43.0
Signature · 1 line
heikki