From f887b383c2389da4d23d335d524565e8ed2974bb Mon Sep 17 00:00:00 2001 From: Woody Lin Date: Thu, 13 Jun 2024 10:11:16 +0800 Subject: [PATCH] watchdog: s3c2410_wdt: Assign s3c_wdt[] until probe complete Assigns device data to `s3c_wdt[cluster_index]` only when probe function completes. Several functions of s3c2410_wdt use the existence of `s3c_wdt[*]` to decide whether the device data is ready to be accessed. This causes an invalid access issue as long as the probe function puts device data to `s3c_wdt[cluster_index]` before completely preparing the content. Fixes the issue by rearranging the assignment order. Bug: 342585125 Change-Id: Idb4c3b71fb2e0518725c697db01e708aa0c7c86b Signed-off-by: Woody Lin (cherry picked from commit d7bd15571d51e658a081d98dfbcc17e3aa104585) --- drivers/watchdog/s3c2410_wdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index c97775cd6..0e33de249 100755 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -1467,7 +1467,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev) dev_err(dev, "Watchdog index property too large.\n"); return -EINVAL; } - s3c_wdt[cluster_index] = wdt; wdt->cluster = cluster_index; wdt->drv_data = s3c2410_get_wdt_drv_data(pdev); @@ -1698,6 +1697,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev) pr_info("Multistage watchdog %sabled", wdt->use_multistage_wdt ? "en" : "dis"); + s3c_wdt[cluster_index] = wdt; return 0; err_unregister: