Skip to content
/ linux Public

Commit 2872b67

Browse files
Xu Yanggregkh
authored andcommitted
usb: roles: get usb role switch from parent only for usb-b-connector
commit 8345b15 upstream. 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. Fixes: 6fadd72 ("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>
1 parent 5295020 commit 2872b67

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/usb/roles/class.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,14 @@ static void *usb_role_switch_match(const struct fwnode_handle *fwnode, const cha
110110
static struct usb_role_switch *
111111
usb_role_switch_is_parent(struct fwnode_handle *fwnode)
112112
{
113-
struct fwnode_handle *parent = fwnode_get_parent(fwnode);
113+
struct fwnode_handle *parent;
114114
struct device *dev;
115115

116+
if (!fwnode_device_is_compatible(fwnode, "usb-b-connector"))
117+
return NULL;
118+
119+
parent = fwnode_get_parent(fwnode);
120+
116121
if (!fwnode_property_present(parent, "usb-role-switch")) {
117122
fwnode_handle_put(parent);
118123
return NULL;

0 commit comments

Comments
 (0)