[PATCH 1/2] driver core: platform: remove software node on release()
From: Bartosz Golaszewski
Date: Fri Apr 10 2026 - 07:53:07 EST
If we pass a software node to a newly created device using struct
platform_device_info, it will not be removed when the device is
released. This may happen when a module creating the device is removed
or on failure in platform_device_add().
When we try to reuse that software node in a subsequent call to
platform_device_register_full(), it will fails with -EBUSY. Add the
missing call to device_remove_software_node() in release path.
Fixes: 0fc434bc2c45 ("driver core: platform: allow attaching software nodes when creating devices")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
---
drivers/base/platform.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 75b4698d0e582e67adafa78c312d75c72fd654cf..a442abb4f1028a91f3c56b51211335678f7f18a2 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -600,6 +600,7 @@ static void platform_device_release(struct device *dev)
pdev.dev);
of_node_put(pa->pdev.dev.of_node);
+ device_remove_software_node(dev);
kfree(pa->pdev.dev.platform_data);
kfree(pa->pdev.mfd_cell);
kfree(pa->pdev.resource);
--
2.47.3