From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: "Mario Limonciello (AMD)" <superm1@kernel.org>
Cc: mario.limonciello@amd.com, gregkh@linuxfoundation.org,
lumag@kernel.org, ukaszb@chromium.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH] usb: typec: ucsi: Fix null pointer dereference in ucsi_sync_control_common
Date: Tue, 16 Dec 2025 14:11:47 +0200 [thread overview]
Message-ID: <aUFMg-3DZ4MZZqHJ@kuha> (raw)
In-Reply-To: <20251214183729.150811-1-superm1@kernel.org>
Sun, Dec 14, 2025 at 12:36:41PM -0600, Mario Limonciello (AMD) kirjoitti:
> 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]
>
> Fixes: 667ecac55861 ("usb: typec: ucsi: return CCI and message from sync_control callback")
> Signed-off-by: Mario Limonciello (AMD) <superm1@kernel.org>
I guess you need the CC stable tag.
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/ucsi/ucsi.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c
> index 9b3df776137a1..7129973f19e7e 100644
> --- a/drivers/usb/typec/ucsi/ucsi.c
> +++ b/drivers/usb/typec/ucsi/ucsi.c
> @@ -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);
> --
> 2.43.0
--
heikki
prev parent reply other threads:[~2025-12-16 12:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-14 18:36 [PATCH] usb: typec: ucsi: Fix null pointer dereference in ucsi_sync_control_common Mario Limonciello (AMD)
2025-12-15 8:12 ` Greg KH
2025-12-16 12:11 ` Heikki Krogerus [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aUFMg-3DZ4MZZqHJ@kuha \
--to=heikki.krogerus@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=lumag@kernel.org \
--cc=mario.limonciello@amd.com \
--cc=superm1@kernel.org \
--cc=ukaszb@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox