Re: [PATCH 5.10 189/491] usb: roles: get usb role switch from parent only for usb-b-connector

Ben Hutchings
2026-04-15T11:55:51Z

[-- Attachment #1: Type: text/plain, Size: 2890 bytes --]

On Mon, 2026-04-13 at 17:57 +0200, Greg Kroah-Hartman wrote:
> 5.10-stable review patch. If anyone has any objections, please let me know.
>
> ------------------
>
> From: Xu Yang <xu.yang_2@nxp.com>
>
> [ Upstream commit 8345b1539faa49fcf9c9439c3cbd97dac6eca171 ]
>
> usb_role_switch_is_parent() was walking up to the parent node and checking
> for the "usb-role-switch" property regardless of the type of the passed
> fwnode. This could cause unrelated device nodes to be probed as potential
> role switch parent, leading to spurious matches and "-EPROBE_DEFER" being
> returned infinitely.
>
> Till now only Type-B connector node will have a parent node which may
> present "usb-role-switch" property and register the role switch device.
> For Type-C connector node, its parent node will always be a Type-C chip
> device which will never register the role switch device. However, it may
> still present a non-boolean "usb-role-switch = <&usb_controller>" property
> for historical compatibility.
>
> So restrict the helper to only operate on Type-B connector when attempting
> to get the role switch from parent node.

Is this safe to backport? It seems like very few device trees on older
branches have the compatible string that will now be required.

Ben.

> Fixes: 6fadd72943b8 ("usb: roles: get usb-role-switch from parent")
> Cc: stable <stable@kernel.org>
> Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
> Tested-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Link: https://patch.msgid.link/20260309074313.2809867-3-xu.yang_2@nxp.com
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> [ replace fwnode_device_is_compatible() call with it's expansion ]
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> drivers/usb/roles/class.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> --- a/drivers/usb/roles/class.c
> +++ b/drivers/usb/roles/class.c
> @@ -108,9 +108,14 @@ static void *usb_role_switch_match(struc
> static struct usb_role_switch *
> usb_role_switch_is_parent(struct fwnode_handle *fwnode)
> {
> - struct fwnode_handle *parent = fwnode_get_parent(fwnode);
> + struct fwnode_handle *parent;
> struct device *dev;
>
> + if (fwnode_property_match_string(fwnode, "compatible", "usb-b-connector") < 0)
> + return NULL;
> +
> + parent = fwnode_get_parent(fwnode);
> +
> if (!fwnode_property_present(parent, "usb-role-switch")) {
> fwnode_handle_put(parent);
> return NULL;
>
>

--
Ben Hutchings
The obvious mathematical breakthrough [to break modern encryption]
would be development of an easy way to factor large prime numbers.
- Bill Gates

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]