diff --git a/drivers/usb/roles/class.c b/drivers/usb/roles/class.c index 97e3d75b19a33..873d89823f5b3 100644 --- a/drivers/usb/roles/class.c +++ b/drivers/usb/roles/class.c @@ -108,10 +108,13 @@ usb_role_switch_is_parent(struct fwnode_handle *fwnode) struct fwnode_handle *parent = fwnode_get_parent(fwnode); struct device *dev; - if (!parent || !fwnode_property_present(parent, "usb-role-switch")) + if (!fwnode_property_present(parent, "usb-role-switch")) { + fwnode_handle_put(parent); return NULL; + } dev = class_find_device_by_fwnode(role_class, parent); + fwnode_handle_put(parent); return dev ? to_role_switch(dev) : ERR_PTR(-EPROBE_DEFER); }