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 <woodylin@google.com>
(cherry picked from commit d7bd15571d51e658a081d98dfbcc17e3aa104585)
This commit is contained in:
Woody Lin 2024-06-13 10:11:16 +08:00 committed by Kreciorek
parent f270792105
commit f887b383c2

View file

@ -1467,7 +1467,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
dev_err(dev, "Watchdog index property too large.\n"); dev_err(dev, "Watchdog index property too large.\n");
return -EINVAL; return -EINVAL;
} }
s3c_wdt[cluster_index] = wdt;
wdt->cluster = cluster_index; wdt->cluster = cluster_index;
wdt->drv_data = s3c2410_get_wdt_drv_data(pdev); 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", pr_info("Multistage watchdog %sabled",
wdt->use_multistage_wdt ? "en" : "dis"); wdt->use_multistage_wdt ? "en" : "dis");
s3c_wdt[cluster_index] = wdt;
return 0; return 0;
err_unregister: err_unregister: