usb: roles: fix a potential use after free
PATCH 1/1 usb: roles: fix a potential use after free
Free the sw structure only after we are done using it. This patch just moves the put_device() down a bit to avoid the use after free.
Fixes 5c54fcac9a9d ("usb: roles: Take care of driver module reference counting")
Signed-off-by Wen Yang <[email protected]>
Cc Heikki Krogerus <[email protected]>
Cc Hans de Goede <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Chunfeng Yun <[email protected]>
Cc Suzuki K Poulose <[email protected]>
--- drivers/usb/roles/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/roles/class.c +1 -1
@@ -169,8 +169,8 @@ struct usb_role_switch *fwnode_usb_role_switch_get(struct fwnode_handle *fwnode)void usb_role_switch_put (struct usb_role_switch *sw) {if (!IS_ERR_OR_NULL (sw)) { -put_device (&sw->dev);module_put (sw->dev.parent->driver->owner); +put_device (&sw->dev); } }EXPORT_SYMBOL_GPL (usb_role_switch_put);
Signature · 1 line
1.8.3.1
Quoted 34 lines · Wen Yang
Free the sw structure only after we are done using it. This patch just moves the
put_device()down a bit to avoid the use after free.Fixes 5c54fcac9a9d ("usb: roles: Take care of driver module reference counting")Signed-off-by Wen Yang <[email protected]>Cc Heikki Krogerus <[email protected]>Cc Hans de Goede <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Chunfeng Yun <[email protected]>Cc Suzuki K Poulose <[email protected]>--- drivers/usb/roles/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/roles/class.c +1
-1@@ -169,8 +169,8 @@ struct usb_role_switch *fwnode_usb_role_switch_get(struct fwnode_handle *fwnode)void usb_role_switch_put (struct usb_role_switch *sw) {if (!IS_ERR_OR_NULL (sw)) { -put_device (&sw->dev);module_put (sw->dev.parent->driver->owner); +put_device (&sw->dev); } }EXPORT_SYMBOL_GPL (usb_role_switch_put);Signature · 1 line
1.8.3.1
Reviewed-by Peter Chen <[email protected]>
Signature · 2 lines
Thanks, Peter Chen
Quoted 33 lines · Wen Yang
Free the sw structure only after we are done using it. This patch just moves the
put_device()down a bit to avoid the use after free.Fixes 5c54fcac9a9d ("usb: roles: Take care of driver module reference counting")Signed-off-by Wen Yang <[email protected]>Cc Heikki Krogerus <[email protected]>Cc Hans de Goede <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Chunfeng Yun <[email protected]>Cc Suzuki K Poulose <[email protected]>--- drivers/usb/roles/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/roles/class.c +1
-1@@ -169,8 +169,8 @@ struct usb_role_switch *fwnode_usb_role_switch_get(struct fwnode_handle *fwnode)void usb_role_switch_put (struct usb_role_switch *sw) {if (!IS_ERR_OR_NULL (sw)) { -put_device (&sw->dev);module_put (sw->dev.parent->driver->owner); +put_device (&sw->dev); } }EXPORT_SYMBOL_GPL (usb_role_switch_put);Signature · 1 line
1.8.3.1
Signature · 1 line
heikki
Heikki Krogerus
Reviewed-byQuoted 5 lines · Heikki Krogerus
Quoted 4 lines · Wen Yang
Free the sw structure only after we are done using it. This patch just moves the
put_device()down a bit to avoid the use after free.
Quoted 9 lines
Quoted 9 lines
Fixes 5c54fcac9a9d ("usb: roles: Take care of driver module reference counting")Signed-off-by Wen Yang <[email protected]>Cc Heikki Krogerus <[email protected]>Cc Hans de Goede <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc Chunfeng Yun <[email protected]>Cc Suzuki K Poulose <[email protected]>
Ups, sorry. I meant:
Reviewed-by Heikki Krogerus <[email protected]>
thanks,
Signature · 1 line
heikki