mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-05 00:20:32 +00:00
usb: roles: fix a potential use after free
commit1848a54319
upstream. 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:5c54fcac9a
("usb: roles: Take care of driver module reference counting") Signed-off-by: Wen Yang <wenyang@linux.alibaba.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Reviewed-by: Peter Chen <peter.chen@nxp.com> Cc: stable <stable@vger.kernel.org> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Chunfeng Yun <chunfeng.yun@mediatek.com> Cc: Suzuki K Poulose <suzuki.poulose@arm.com> Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org Link: https://lore.kernel.org/r/20191124142236.25671-1-wenyang@linux.alibaba.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3d1eef3858
commit
c3dde73859
1 changed files with 1 additions and 1 deletions
|
@ -130,8 +130,8 @@ EXPORT_SYMBOL_GPL(usb_role_switch_get);
|
||||||
void usb_role_switch_put(struct usb_role_switch *sw)
|
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);
|
module_put(sw->dev.parent->driver->owner);
|
||||||
|
put_device(&sw->dev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(usb_role_switch_put);
|
EXPORT_SYMBOL_GPL(usb_role_switch_put);
|
||||||
|
|
Loading…
Reference in a new issue