All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: Hector Martin <marcan@marcan.st>
Cc: linux-usb@vger.kernel.org
Subject: [bug report] usb: typec: tipd: Handle mode transitions for CD321x
Date: Thu, 18 Sep 2025 12:52:18 +0300	[thread overview]
Message-ID: <aMvWUtyvtXH2AkIA@stanley.mountain> (raw)

Hello Hector Martin,

Commit 82432bbfb9e8 ("usb: typec: tipd: Handle mode transitions for
CD321x") from Sep 14, 2025 (linux-next), leads to the following
Smatch static checker warning:

	drivers/usb/typec/tipd/core.c:821 cd321x_update_work()
	error: 'tps->partner' dereferencing possible ERR_PTR()

drivers/usb/typec/tipd/core.c
    805         /* Set up partner if we were previously disconnected (or changed). */
    806         if (!tps->partner) {
    807                 struct typec_partner_desc desc;
    808 
    809                 desc.usb_pd = is_pd;
    810                 desc.accessory = TYPEC_ACCESSORY_NONE; /* XXX: handle accessories */
    811                 desc.identity = NULL;
    812 
    813                 if (desc.usb_pd)
    814                         desc.identity = &st.partner_identity;
    815 
    816                 tps->partner = typec_register_partner(tps->port, &desc);
    817                 if (IS_ERR(tps->partner))
                                   ^^^^^^^^^^^^
    818                         dev_warn(tps->dev, "%s: failed to register partnet\n", __func__);

tps->partner is an error pointer.

    819 
    820                 if (desc.identity) {
--> 821                         typec_partner_set_identity(tps->partner);
                                                           ^^^^^^^^^^^^
but typec_partner_set_identity() dereferences it.

    822                         cd321x->cur_partner_identity = st.partner_identity;
    823                 }
    824         }
    825 
    826         /* Update the TypeC MUX/PHY state */
    827         cd321x_typec_update_mode(tps, &st);
    828 
    829         /* Launch the USB role switch */
    830         usb_role_switch_set_role(tps->role_sw, new_role);
    831 
    832         power_supply_changed(tps->psy);
    833 }

regards,
dan carpenter

                 reply	other threads:[~2025-09-18  9:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=aMvWUtyvtXH2AkIA@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=marcan@marcan.st \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.