From: sashiko-bot@kernel.org
To: "Chen-Yu Tsai" <wenst@chromium.org>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 05/13] usb: hub: Associate port@ fwnode with USB port device
Date: Fri, 03 Jul 2026 11:18:02 +0000 [thread overview]
Message-ID: <20260703111802.A8A601F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260703110317.1283411-6-wenst@chromium.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The firmware node reference obtained from `fwnode_graph_get_port_by_id()` is leaked because it is never explicitly released.
--
commit 25f9337168757350400d5fa5ab05e87193277473
Author: Chen-Yu Tsai <wenst@chromium.org>
usb: hub: Associate port@ fwnode with USB port device
This commit assigns a firmware node to a USB port device if the hub's
firmware node is not an ACPI node. This association allows later M.2 slot
power sequencing providers to match against the requesting port.
> diff --git a/drivers/usb/core/port.c b/drivers/usb/core/port.c
> index b1364f0c384ce..1088776ef750b 100644
> --- a/drivers/usb/core/port.c
> +++ b/drivers/usb/core/port.c
[ ... ]
> @@ -780,6 +781,13 @@ int usb_hub_create_port_device(struct usb_hub *hub, int port1)
> port_dev->dev.driver = &usb_port_driver;
> dev_set_name(&port_dev->dev, "%s-port%d", dev_name(&hub->hdev->dev),
> port1);
> + /*
> + * ACPI FW nodes are associated later when device_register() happens.
> + * Skip assigning one here to avoid potential conflicts.
> + */
> + if (!is_acpi_node(dev_fwnode(&hdev->dev)))
> + device_set_node(&port_dev->dev,
> + fwnode_graph_get_port_by_id(dev_fwnode(&hdev->dev), port1));
[Severity: Medium]
Does this code leak the fwnode_handle reference?
fwnode_graph_get_port_by_id() increments the reference count of the returned
firmware node, and the caller is expected to release it.
Since device_set_node() merely assigns dev->fwnode without taking ownership
of the reference, the driver core doesn't automatically drop it when the
device is destroyed.
Looking at usb_port_device_release() in drivers/usb/core/port.c, it
only frees the port structures:
static void usb_port_device_release(struct device *dev)
{
struct usb_port *port_dev = to_usb_port(dev);
kfree(port_dev->req);
kfree(port_dev);
}
Without a corresponding fwnode_handle_put(), will this result in a reference
leak whenever a USB hub is disconnected, or if device_register() fails on the
error path?
> mutex_init(&port_dev->status_lock);
> retval = device_register(&port_dev->dev);
> if (retval) {
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260703110317.1283411-1-wenst@chromium.org?part=5
next prev parent reply other threads:[~2026-07-03 11:18 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 11:03 [PATCH v3 00/13] arm64: mediatek: Add M.2 E-key slot on Chromebooks Chen-Yu Tsai
2026-07-03 11:03 ` [PATCH v3 01/13] device property: Add fwnode_graph_get_port_by_id() Chen-Yu Tsai
2026-07-03 11:15 ` sashiko-bot
2026-07-03 11:03 ` [PATCH v3 02/13] device property: Add fwnode_graph_get_next_port_endpoint() Chen-Yu Tsai
2026-07-03 11:17 ` sashiko-bot
2026-07-03 12:04 ` Bartosz Golaszewski
2026-07-03 12:46 ` Andy Shevchenko
2026-07-03 11:03 ` [PATCH v3 03/13] power: sequencing: Add pwrseq_power_is_on() Chen-Yu Tsai
2026-07-03 11:16 ` sashiko-bot
2026-07-03 12:07 ` Bartosz Golaszewski
2026-07-03 12:17 ` Chen-Yu Tsai
2026-07-03 13:18 ` Bartosz Golaszewski
2026-07-03 11:03 ` [PATCH v3 04/13] usb: hub: Return actual error from hub_configure() in hub_probe() Chen-Yu Tsai
2026-07-03 11:03 ` [PATCH v3 05/13] usb: hub: Associate port@ fwnode with USB port device Chen-Yu Tsai
2026-07-03 11:18 ` sashiko-bot [this message]
2026-07-03 12:09 ` Bartosz Golaszewski
2026-07-03 13:01 ` Andy Shevchenko
2026-07-03 13:25 ` Chen-Yu Tsai
2026-07-03 13:34 ` Andy Shevchenko
2026-07-03 11:03 ` [PATCH v3 06/13] usb: hub: Pass |struct usb_port*| to usb_port_is_power_on() Chen-Yu Tsai
2026-07-03 13:11 ` Andy Shevchenko
2026-07-03 13:17 ` Chen-Yu Tsai
2026-07-03 13:33 ` Andy Shevchenko
2026-07-06 11:08 ` Chen-Yu Tsai
2026-07-06 16:00 ` Andy Shevchenko
2026-07-07 4:29 ` Chen-Yu Tsai
2026-07-03 11:03 ` [PATCH v3 07/13] usb: hub: Use usb_hub_set_port_power() to control port power everywhere Chen-Yu Tsai
2026-07-03 12:12 ` Bartosz Golaszewski
2026-07-03 11:03 ` [PATCH v3 08/13] usb: hub: Power on connected M.2 E-key connectors with power sequencing API Chen-Yu Tsai
2026-07-03 11:29 ` sashiko-bot
2026-07-03 12:41 ` Bartosz Golaszewski
2026-07-03 12:58 ` Chen-Yu Tsai
2026-07-03 13:16 ` Bartosz Golaszewski
2026-07-03 13:20 ` Chen-Yu Tsai
2026-07-03 13:19 ` Andy Shevchenko
2026-07-03 11:03 ` [PATCH v3 09/13] dt-bindings: usb: mediatek,mtk-xhci: Switch to ports for USB connections Chen-Yu Tsai
2026-07-05 9:43 ` Krzysztof Kozlowski
2026-07-03 11:03 ` [PATCH v3 10/13] power: sequencing: pcie-m2: support matching on remote "port" node Chen-Yu Tsai
2026-07-03 12:57 ` Andy Shevchenko
2026-07-03 11:03 ` [PATCH v3 11/13] power: sequencing: pcie-m2: Add usb and sdio targets for E-key connector Chen-Yu Tsai
2026-07-03 11:03 ` [PATCH v3 12/13] arm64: dts: mediatek: mt8195-cherry: Add M.2 E-key slot Chen-Yu Tsai
2026-07-03 11:03 ` [PATCH v3 13/13] arm64: dts: mediatek: mt8188-geralt: Add WiFi/BT as " Chen-Yu Tsai
2026-07-03 13:19 ` [PATCH v3 00/13] arm64: mediatek: Add M.2 E-key slot on Chromebooks Bartosz Golaszewski
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=20260703111802.A8A601F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wenst@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 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.