From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Ethan Tidmore <ethantidmore06@gmail.com>
Cc: gregkh@linuxfoundation.org, sven@kernel.org, neal@gompa.dev,
marcan@marcan.st, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: typec: Fix error pointer dereference
Date: Mon, 23 Feb 2026 17:07:15 +0200 [thread overview]
Message-ID: <aZxtIw6tJl-g397V@kuha> (raw)
In-Reply-To: <20260218214621.38154-1-ethantidmore06@gmail.com>
Wed, Feb 18, 2026 at 03:46:21PM -0600, Ethan Tidmore wrote:
> The variable tps->partner is checked for an error pointer and then if it
> is, it sends an error message but does not return and then immediately
> dereferenced a few lines below:
>
> tps->partner = typec_register_partner(tps->port, &desc);
> if (IS_ERR(tps->partner))
> dev_warn(tps->dev, "%s: failed to register partnet\n", __func__);
>
> if (desc.identity) {
> typec_partner_set_identity(tps->partner);
> cd321x->cur_partner_identity = st.partner_identity;
> }
>
> Add early return and fix spelling mistake in error message.
>
> Detected by Smatch:
> drivers/usb/typec/tipd/core.c:827 cd321x_update_work() error:
> 'tps->partner' dereferencing possible ERR_PTR()
>
> Fixes: 82432bbfb9e83 ("usb: typec: tipd: Handle mode transitions for CD321x")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> ---
> drivers/usb/typec/tipd/core.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/typec/tipd/core.c b/drivers/usb/typec/tipd/core.c
> index e2b26af2b84a..43faec794b95 100644
> --- a/drivers/usb/typec/tipd/core.c
> +++ b/drivers/usb/typec/tipd/core.c
> @@ -820,8 +820,10 @@ static void cd321x_update_work(struct work_struct *work)
> desc.identity = &st.partner_identity;
>
> tps->partner = typec_register_partner(tps->port, &desc);
> - if (IS_ERR(tps->partner))
> - dev_warn(tps->dev, "%s: failed to register partnet\n", __func__);
> + if (IS_ERR(tps->partner)) {
> + dev_warn(tps->dev, "%s: failed to register partner\n", __func__);
> + return;
> + }
>
> if (desc.identity) {
> typec_partner_set_identity(tps->partner);
> --
> 2.53.0
--
heikki
prev parent reply other threads:[~2026-02-23 15:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 21:46 [PATCH] usb: typec: Fix error pointer dereference Ethan Tidmore
2026-02-23 15:07 ` 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=aZxtIw6tJl-g397V@kuha \
--to=heikki.krogerus@linux.intel.com \
--cc=ethantidmore06@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=marcan@marcan.st \
--cc=neal@gompa.dev \
--cc=sven@kernel.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