Skip to content

Commit 5736015

Browse files
stonezdmWim Van Sebroeck
authored andcommitted
watchdog: cpu5wdt.c: Fix use-after-free bug caused by cpu5wdt_trigger
When the cpu5wdt module is removing, the origin code uses del_timer() to de-activate the timer. If the timer handler is running, del_timer() could not stop it and will return directly. If the port region is released by release_region() and then the timer handler cpu5wdt_trigger() calls outb() to write into the region that is released, the use-after-free bug will happen. Change del_timer() to timer_shutdown_sync() in order that the timer handler could be finished before the port region is released. Fixes: e09d9c3 ("watchdog: cpu5wdt.c: add missing del_timer call") Signed-off-by: Duoming Zhou <[email protected]> Reviewed-by: Guenter Roeck <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Guenter Roeck <[email protected]> Signed-off-by: Wim Van Sebroeck <[email protected]>
1 parent 1f6602c commit 5736015

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/watchdog/cpu5wdt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ static void cpu5wdt_exit(void)
252252
if (cpu5wdt_device.queue) {
253253
cpu5wdt_device.queue = 0;
254254
wait_for_completion(&cpu5wdt_device.stop);
255-
del_timer(&cpu5wdt_device.timer);
255+
timer_shutdown_sync(&cpu5wdt_device.timer);
256256
}
257257

258258
misc_deregister(&cpu5wdt_misc);

0 commit comments

Comments
 (0)