[PATCH 13/24] dm: core: Correct error handling when event fails

Simon Glass sjg at chromium.org
Sun Aug 13 16:26:41 CEST 2023


Follow the correct path in device_probe() when and event handler fails.
This avoids getting into a strange state where the device appears to be
activated but is not.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 drivers/core/device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 6e26b64fb812..60f8d6700ad4 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -598,9 +598,10 @@ int device_probe(struct udevice *dev)
 
 	ret = device_notify(dev, EVT_DM_POST_PROBE);
 	if (ret)
-		return ret;
+		goto fail_event;
 
 	return 0;
+fail_event:
 fail_uclass:
 	if (device_remove(dev, DM_REMOVE_NORMAL)) {
 		dm_warn("%s: Device '%s' failed to remove on error path\n",
-- 
2.41.0.640.ga95def55d0-goog



More information about the U-Boot mailing list