patch "usb: roles: Take care of driver module reference counting" added to usb-linus
Subsystems (2)
This is a note to let you know that I've just added the patch titled
usb: roles: Take care of driver module reference counting
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
Quoted 1 line
From
5c54fcac9a9de559b444ac63ec3cd82f1d157a0bMon Sep 17 00:00:00 2001
From: Heikki Krogerus <[email protected]>
Date: Wed, 19 Sep 2018 10:58:05 +0300
Subject: usb: roles: Take care of driver module reference counting
This fixes potential "BUG: unable to handle kernel paging request at ..." from happening.
--- drivers/usb/common/roles.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/usb/common/roles.c +12 -3
@@ -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);
Signature · 1 line
2.19.0