Skip to contentSkip to conversation

tty: ipwireless: shut down setup timer before freeing hardware

PATCH In review Hongyan Xu 3 participants 3 messages Aug 6

Subsystems (2)
lore
Share & tools
lore

Hongyan Xu

author
#0 lore raw

PATCH 1/1 tty: ipwireless: shut down setup timer before freeing hardware

ipwireless_stop_interrupts() uses timer_delete() for a timer whose callback can rearm itself. timer_delete() neither waits for a running callback nor prevents that callback from rearming the timer. The callback can therefore continue to access struct ipw_hardware after ipwireless_hardware_free() has freed it.

Use timer_shutdown_sync() so teardown waits for the callback and prevents any further rearming.

Fixes 099dc4fb6265 ("ipwireless: driver for PC Card 3G/UMTS modem")
---
 drivers/tty/ipwireless/hardware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/ipwireless/hardware.c +1 -1
index 0bfcbca6e2df..fb3554a6e04b 100644
@@ -1721,7 +1721,7 @@ void ipwireless_stop_interrupts(struct ipw_hardware *hw)
 	if (!hw->shutting_down) {
 		/* Tell everyone we are going down. */
 		hw->shutting_down = 1;
-		timer_delete(&hw->setup_timer);
+		timer_shutdown_sync(&hw->setup_timer);
 
 		/* Prevent the hardware from sending any more interrupts */
 		do_close_hardware(hw);
Signature · 1 line
2.50.1.windows.1
#1 lore raw
Quoted 32 lines · Hongyan Xu

ipwireless_stop_interrupts() uses timer_delete() for a timer whose callback can rearm itself. timer_delete() neither waits for a running callback nor prevents that callback from rearming the timer. The callback can therefore continue to access struct ipw_hardware after ipwireless_hardware_free() has freed it.

Use timer_shutdown_sync() so teardown waits for the callback and prevents any further rearming.

Fixes 099dc4fb6265 ("ipwireless: driver for PC Card 3G/UMTS modem")
---
 drivers/tty/ipwireless/hardware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/ipwireless/hardware.c +1 -1
index 0bfcbca6e2df..fb3554a6e04b 100644
@@ -1721,7 +1721,7 @@ void ipwireless_stop_interrupts(struct ipw_hardware *hw)
 	if (!hw->shutting_down) {
 		/* Tell everyone we are going down. */
 		hw->shutting_down = 1;
-		timer_delete(&hw->setup_timer);
+		timer_shutdown_sync(&hw->setup_timer);
 
 		/* Prevent the hardware from sending any more interrupts */
 		do_close_hardware(hw);
Signature · 1 line
2.50.1.windows.1

How was this tested?

#2 lore raw
In reply to Hongyan Xu
Quoted 21 lines · Hongyan Xu

ipwireless_stop_interrupts() uses timer_delete() for a timer whose callback can rearm itself. timer_delete() neither waits for a running callback nor prevents that callback from rearming the timer. The callback can therefore continue to access struct ipw_hardware after ipwireless_hardware_free() has freed it.

Use timer_shutdown_sync() so teardown waits for the callback and prevents any further rearming.

Fixes 099dc4fb6265 ("ipwireless: driver for PC Card 3G/UMTS modem")
---
 drivers/tty/ipwireless/hardware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/ipwireless/hardware.c +0 -0
index 0bfcbca6e2df..fb3554a6e04b 100644

drivers/tty/ipwireless/hardware.c void ipwireless_stop_interrupts(struct ipw_hardware *hw) · line 1727

Quoted 8 lines
drivers/tty/ipwireless/hardware.c +1 -1
@@ -1721,7 +1721,7 @@ void ipwireless_stop_interrupts(struct ipw_hardware *hw)
 	if (!hw->shutting_down) {
 		/* Tell everyone we are going down. */
 		hw->shutting_down = 1;
-		timer_delete(&hw->setup_timer);
+		timer_shutdown_sync(&hw->setup_timer);
 
 		/* Prevent the hardware from sending any more interrupts */
 		do_close_hardware(hw);

The driver is queued for removal.

Signature · 2 lines
Jiri Kosina
SUSE Labs