Skip to content
Snippets Groups Projects
Commit dc68375e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Revert "usb: roles: fix NULL pointer issue when put module's reference"


This reverts commit e279bf8e which is
commit 1c9be138 upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.  It's not a "real" break, and
we can work around it, but this really does not affect Android systems,
so it's safe to drop for now.

Bug: 161946584
Change-Id: Ic12e606a51d05425d81a81d520b800bc24c6eac4
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 048142f2
No related merge requests found
......@@ -19,7 +19,6 @@ static struct class *role_class;
struct usb_role_switch {
struct device dev;
struct mutex lock; /* device lock*/
struct module *module; /* the module this device depends on */
enum usb_role role;
/* From descriptor */
......@@ -134,7 +133,7 @@ struct usb_role_switch *usb_role_switch_get(struct device *dev)
usb_role_switch_match);
if (!IS_ERR_OR_NULL(sw))
WARN_ON(!try_module_get(sw->module));
WARN_ON(!try_module_get(sw->dev.parent->driver->owner));
return sw;
}
......@@ -156,7 +155,7 @@ struct usb_role_switch *fwnode_usb_role_switch_get(struct fwnode_handle *fwnode)
sw = fwnode_connection_find_match(fwnode, "usb-role-switch",
NULL, usb_role_switch_match);
if (!IS_ERR_OR_NULL(sw))
WARN_ON(!try_module_get(sw->module));
WARN_ON(!try_module_get(sw->dev.parent->driver->owner));
return sw;
}
......@@ -171,7 +170,7 @@ EXPORT_SYMBOL_GPL(fwnode_usb_role_switch_get);
void usb_role_switch_put(struct usb_role_switch *sw)
{
if (!IS_ERR_OR_NULL(sw)) {
module_put(sw->module);
module_put(sw->dev.parent->driver->owner);
put_device(&sw->dev);
}
}
......@@ -188,18 +187,15 @@ struct usb_role_switch *
usb_role_switch_find_by_fwnode(const struct fwnode_handle *fwnode)
{
struct device *dev;
struct usb_role_switch *sw = NULL;
if (!fwnode)
return NULL;
dev = class_find_device_by_fwnode(role_class, fwnode);
if (dev) {
sw = to_role_switch(dev);
WARN_ON(!try_module_get(sw->module));
}
if (dev)
WARN_ON(!try_module_get(dev->parent->driver->owner));
return sw;
return dev ? to_role_switch(dev) : NULL;
}
EXPORT_SYMBOL_GPL(usb_role_switch_find_by_fwnode);
......@@ -332,7 +328,6 @@ usb_role_switch_register(struct device *parent,
sw->set = desc->set;
sw->get = desc->get;
sw->module = parent->driver->owner;
sw->dev.parent = parent;
sw->dev.fwnode = desc->fwnode;
sw->dev.class = role_class;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment