Skip to contentSkip to conversation

patch "usb: roles: fix a potential use after free" added to usb-linus

PATCH [email protected] 1 participant 1 message Dec 10, 2019

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

usb: roles: fix a potential use after free

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.

From 1848a543191ae32e558bb0a5974ae7c38ebd86fc Mon Sep 17 00:00:00 2001
From: Wen Yang <[email protected]>
Date: Sun, 24 Nov 2019 22:22:36 +0800
Subject: 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")
Cc stable <[email protected]>
Cc Hans de Goede <[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
index 8273126ffdf4..63a00ff26655 100644
@@ -169,8 +169,8 @@ EXPORT_SYMBOL_GPL(fwnode_usb_role_switch_get);
 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
2.24.0