[PATCH 3/8] memory: stm32_omm: Depopulate child devices before disabling clocks

Lee Jones lee at kernel.org
Wed Dec 2 01:33:50 PST 2026


stm32_omm_probe() registers child OSPI devices via
devm_of_platform_populate(), whose devres cleanup runs after
stm32_omm_remove() returns.  When CR_MUXEN is set, stm32_omm_remove()
disables the OSPI child clocks while the child drivers are still bound
and may access their hardware during removal.

Populate child devices with of_platform_populate() and explicitly call
of_platform_depopulate() on partial population failure and at the start
of stm32_omm_remove() before disabling the child clocks.

Fixes: 8181d061dcff ("memory: Add STM32 Octo Memory Manager driver")
Closes: https://sashiko.dev/#/bug/linux-24c34b63-4c84-4d67-8ee1-eb7964079c44
Cc: stable at vger.kernel.org
Signed-off-by: Lee Jones <lee at kernel.org>
---
 drivers/memory/stm32_omm.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/stm32_omm.c b/drivers/memory/stm32_omm.c
index 3599683ab04a..5ff63870421f 100644
--- a/drivers/memory/stm32_omm.c
+++ b/drivers/memory/stm32_omm.c
@@ -368,8 +368,9 @@ static int stm32_omm_probe(struct platform_device *pdev)
 			return ret;
 	}
 
-	ret = devm_of_platform_populate(dev);
+	ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
 	if (ret) {
+		of_platform_depopulate(dev);
 		if (omm->cr & CR_MUXEN)
 			stm32_omm_toggle_child_clock(&pdev->dev, false);
 
@@ -383,6 +384,8 @@ static void stm32_omm_remove(struct platform_device *pdev)
 {
 	struct stm32_omm *omm = platform_get_drvdata(pdev);
 
+	of_platform_depopulate(&pdev->dev);
+
 	if (omm->cr & CR_MUXEN)
 		stm32_omm_toggle_child_clock(&pdev->dev, false);
 }
-- 
2.56.1.911.g883d8bcb20-goog




More information about the linux-arm-kernel mailing list