Re: [PATCH 6/6] watchdog: rdc321x: initialize device state before registration

From: Guenter Roeck

Date: Wed Oct 28 2026 - 11:00:03 EST


On 10/27/26 21:48, Jiale Yao wrote:
misc_register() exposes the watchdog before its lock, completion, and
timer are initialized. A userspace operation racing probe can therefore
use any of these objects before it is ready.

Finish initializing the watchdog state before registering the misc
device.

Fixes: b3e8f2c13ae9 ("[WATCHDOG] Add support for the built-int RDC R-321x SoC watchdog")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>

I am not going to apply this (or similar) patches.
If you do have hardware utilizing this watchdog, pleae convert the driver
to use the watchdog subsystem. Otherwise, please leave it alone.

Thanks,
Guenter

---
drivers/watchdog/rdc321x_wdt.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/watchdog/rdc321x_wdt.c b/drivers/watchdog/rdc321x_wdt.c
index 8955177072fa..a2520d8d5c90 100644
--- a/drivers/watchdog/rdc321x_wdt.c
+++ b/drivers/watchdog/rdc321x_wdt.c
@@ -233,12 +233,6 @@ static int rdc321x_wdt_probe(struct platform_device *pdev)
rdc321x_wdt_device.queue = 0;
rdc321x_wdt_device.default_ticks = ticks;
- err = misc_register(&rdc321x_wdt_misc);
- if (err < 0) {
- dev_err(&pdev->dev, "misc_register failed\n");
- return err;
- }
-
spin_lock_init(&rdc321x_wdt_device.lock);
/* Reset the watchdog */
@@ -251,6 +245,12 @@ static int rdc321x_wdt_probe(struct platform_device *pdev)
timer_setup(&rdc321x_wdt_device.timer, rdc321x_wdt_trigger, 0);
+ err = misc_register(&rdc321x_wdt_misc);
+ if (err < 0) {
+ dev_err(&pdev->dev, "misc_register failed\n");
+ return err;
+ }
+
dev_info(&pdev->dev, "watchdog init success\n");
return 0;