mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
usb: roles: Take care of driver module reference counting
This fixes potential "BUG: unable to handle kernel paging
request at ..." from happening.
Fixes: fde0aa6c17 ("usb: common: Small class for USB role switches")
Cc: <[email protected]>
Acked-by: Hans de Goede <[email protected]>
Tested-by: Hans de Goede <[email protected]>
Signed-off-by: Heikki Krogerus <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
This commit is contained in:
parent
c9a4cb204e
commit
5c54fcac9a
1 changed files with 12 additions and 3 deletions
|
|
@ -109,8 +109,15 @@ static void *usb_role_switch_match(struct device_connection *con, int ep,
|
|||
*/
|
||||
struct usb_role_switch *usb_role_switch_get(struct device *dev)
|
||||
{
|
||||
return device_connection_find_match(dev, "usb-role-switch", NULL,
|
||||
usb_role_switch_match);
|
||||
struct usb_role_switch *sw;
|
||||
|
||||
sw = device_connection_find_match(dev, "usb-role-switch", NULL,
|
||||
usb_role_switch_match);
|
||||
|
||||
if (!IS_ERR_OR_NULL(sw))
|
||||
WARN_ON(!try_module_get(sw->dev.parent->driver->owner));
|
||||
|
||||
return sw;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(usb_role_switch_get);
|
||||
|
||||
|
|
@ -122,8 +129,10 @@ EXPORT_SYMBOL_GPL(usb_role_switch_get);
|
|||
*/
|
||||
void usb_role_switch_put(struct usb_role_switch *sw)
|
||||
{
|
||||
if (!IS_ERR_OR_NULL(sw))
|
||||
if (!IS_ERR_OR_NULL(sw)) {
|
||||
put_device(&sw->dev);
|
||||
module_put(sw->dev.parent->driver->owner);
|
||||
}
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(usb_role_switch_put);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue