Re: [PATCH -next] watchdog: Fix possible use-after-free by calling del_timer_sync()

From: Vladimir Zapolskiy
Date: Wed May 12 2021 - 15:35:24 EST


On 5/12/21 9:57 AM, Zou Wei wrote:
This driver's remove path calls del_timer(). However, that function
does not wait until the timer handler finishes. This means that the
timer handler may still be running after the driver's remove function
has finished, which would result in a use-after-free.

Fix by calling del_timer_sync(), which makes sure the timer handler
has finished, and unable to re-schedule itself.

Reported-by: Hulk Robot <hulkci@xxxxxxxxxx>
Signed-off-by: Zou Wei <zou_wei@xxxxxxxxxx>

Acked-by: Vladimir Zapolskiy <vz@xxxxxxxxx>

--
Best wishes,
Vladimir