[PATCH] watchdog: fix error in probe() of s3c2410_wdt (reset at booting)

Russell King - ARM Linux linux at arm.linux.org.uk
Fri Jan 13 06:11:17 EST 2012


On Fri, Jan 13, 2012 at 02:14:23PM +0900, MyungJoo Ham wrote:
> Probe function of s3c2410 watchdog calls request_irq before initializing
> required value (wdt_count). This incurs resetting watchdog counter value
> and watchdog-reboot during booting up.
> 
> This patch addresses such an issue by calling request_irq later.
> 
> Error handling in probe function and calling oder in remove function are
> also revised accordingly.

On the other hand, this patch violates the general principle that you set
the device up _before_ you publish it to userspace.

In the case where you add the watchdog device, but then the subsequent
request_irq() fails, there is a window where the watchdog device could
be opened and started.  You then fall out through the error paths, and
the module could be removed.

Don't do this.  Always setup the device first.  Then publish it.  Never
the other way around.



More information about the linux-arm-kernel mailing list