Skip to contentSkip to conversation

usb: typec: stusb160x: disable the interrupt before tearing down

PATCH In review Myeonghun Pak 3 participants 3 messages Nov 12 – Nov 17

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb: typec: stusb160x: disable the interrupt before tearing down

The devm-managed IRQ remains active while stusb160x_remove() tears down the partner, VBUS, role switch and Type-C port. An attach or detach event can race with partner removal or access the port and role switch after they are released.

Disable and synchronize the IRQ at the start of remove(), before any of these resources are torn down.

Found by a static analysis tool under development. Not tested on hardware.

Fixes da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")

---

 drivers/usb/typec/stusb160x.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/typec/stusb160x.c +3 -0
index a2ec0565bd85..ec2f4d7f7ed3 100644
@@ -801,6 +801,9 @@ static void stusb160x_remove(struct i2c_client *client)
 {
 	struct stusb160x *chip = i2c_get_clientdata(client);
 
+	if (client->irq)
+		disable_irq(client->irq);
+
 	if (chip->partner) {
 		typec_unregister_partner(chip->partner);
 		chip->partner = NULL;

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47

Signature · 1 line
2.43.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 8 lines

The devm-managed IRQ remains active while stusb160x_remove() tears down the partner, VBUS, role switch and Type-C port. An attach or detach event can race with partner removal or access the port and role switch after they are released.

Disable and synchronize the IRQ at the start of remove(), before any of these resources are torn down.

Quoted 8 lines

Found by a static analysis tool under development. Not tested on hardware.

Fixes da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
maintainer
#2 lore raw
In reply to Myeonghun Pak
Quoted 10 lines · Myeonghun Pak

The devm-managed IRQ remains active while stusb160x_remove() tears down the partner, VBUS, role switch and Type-C port. An attach or detach event can race with partner removal or access the port and role switch after they are released.

Disable and synchronize the IRQ at the start of remove(), before any of these resources are torn down.

Found by a static analysis tool under development. Not tested on hardware.

The same question here. Why still use the devm_* to request the irq?

Thanks,

Quoted 28 lines
Fixes da0cb6310094 ("usb: typec: add support for STUSB160x Type-C controller family")

---

 drivers/usb/typec/stusb160x.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/usb/typec/stusb160x.c +3 -0
index a2ec0565bd85..ec2f4d7f7ed3 100644
@@ -801,6 +801,9 @@ static void stusb160x_remove(struct i2c_client *client)
 {
 	struct stusb160x *chip = i2c_get_clientdata(client);
 
+	if (client->irq)
+		disable_irq(client->irq);
+
 	if (chip->partner) {
 		typec_unregister_partner(chip->partner);
 		chip->partner = NULL;

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47

Signature · 1 line
2.43.0
Signature · 1 line
heikki