Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Amber Kao" <amber.kao@ite.com.tw>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v6 2/2] usb: typec: ucsi: Add ITE IT8851/IT8853 Type-C PD controller driver
Date: Fri, 31 Jul 2026 10:13:57 +0000	[thread overview]
Message-ID: <20260731101358.2D5291F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260731-ucsi-itepd-v6-2-d25ae12b181f@ite.com.tw>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Potential Use-After-Free in `itepd_remove` due to tearing down the IRQ handler after `ucsi_unregister`.
- [Low] The `itepd_id_table` array does not use named initializers.
--

--- Patch [2]: [PATCH v6 2/2] usb: typec: ucsi: Add ITE IT8851/IT8853 Type-C PD controller driver ---
commit d3337d48cd9d0171c8064301690b4facc2758392
Author: Amber Kao <amber.kao@ite.com.tw>

usb: typec: ucsi: Add ITE IT8851/IT8853 Type-C PD controller driver

This commit adds a UCSI driver for the ITE IT8851 and IT8853 I2C-based
USB Type-C Power Delivery controllers. It implements the necessary UCSI
operations and uses a shared interrupt line to process events.

diff --git a/drivers/usb/typec/ucsi/ucsi_itepd.c b/drivers/usb/typec/ucsi/ucsi_itepd.c
new file mode 100644
index 0000000000000..a639b3d32535f
--- /dev/null
+++ b/drivers/usb/typec/ucsi/ucsi_itepd.c
[ ... ]
> +static void itepd_remove(struct i2c_client *client)
> +{
> +	struct itepd *itepd = i2c_get_clientdata(client);
> +
> +	ucsi_unregister(itepd->ucsi);
> +	free_irq(client->irq, itepd);

[Severity: High]
Could this teardown order cause a use-after-free if an interrupt fires before
the IRQ is freed?

When ucsi_unregister() is called, it frees the ucsi->connector array. If a
hardware interrupt triggers right after that, but before free_irq() completes,
the interrupt handler will call ucsi_notify_common().

Inside ucsi_notify_common(), the freed array is accessed:

drivers/usb/typec/ucsi/ucsi.c:ucsi_notify_common() {
    ...
    if (UCSI_CCI_CONNECTOR(cci)) {
        if (!ucsi->cap.num_connectors || ...)
            ucsi_connector_change(ucsi, UCSI_CCI_CONNECTOR(cci));
    }
    ...
}

And ucsi_connector_change() uses the dangling pointer:

drivers/usb/typec/ucsi/ucsi.c:ucsi_connector_change() {
    ...
    con = &ucsi->connector[num - 1];

    if (!test_and_set_bit(EVENT_PENDING, &ucsi->flags))
        schedule_work(&con->work);
    ...
}

Should free_irq() be called before ucsi_unregister() to ensure the handler
is fully disabled first?

> +	ucsi_destroy(itepd->ucsi);
> +}
> +
> +static const struct of_device_id itepd_of_match_table[] = {
> +	{ .compatible = "ite,it8851" },
> +	{}
> +};
> +MODULE_DEVICE_TABLE(of, itepd_of_match_table);
> +
> +static const struct i2c_device_id itepd_id_table[] = {
> +	{ "ucsi_itepd", 0 },

[Severity: Low]
Does this array need to use named initializers?

The I2C subsystem guidelines request that initialized arrays of type
struct i2c_device_id use named initializers, such as:
{ .name = "ucsi_itepd", .driver_data = 0 }

> +	{}
> +};

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260731-ucsi-itepd-v6-0-d25ae12b181f@ite.com.tw?part=2

      reply	other threads:[~2026-07-31 10:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-31 10:02 [PATCH v6 0/2] usb: typec: ucsi: Add ITE IT8851/IT8853 support Amber Kao
2026-07-31 10:02 ` [PATCH v6 1/2] dt-bindings: usb: Add ITE IT8851/IT8853 Type-C PD controllers Amber Kao
2026-07-31 10:09   ` sashiko-bot
2026-07-31 10:02 ` [PATCH v6 2/2] usb: typec: ucsi: Add ITE IT8851/IT8853 Type-C PD controller driver Amber Kao
2026-07-31 10:13   ` sashiko-bot [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=20260731101358.2D5291F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=amber.kao@ite.com.tw \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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