From: Simon Glass <sjg@chromium.org>
Date: Thu, 24 Aug 2023 19:55:35 +0000 (-0600)
Subject: dm: core: Correct error handling when event fails
X-Git-Tag: v2025.01-rc5-pxa1908~847^2~27^2~13
X-Git-Url: http://git.dujemihanovic.xyz/%22http:/www.sics.se/static/login.html?a=commitdiff_plain;h=c837a1423c876669bfd963e1ded518b9e497946d;p=u-boot.git

dm: core: Correct error handling when event fails

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@chromium.org>
---

diff --git a/drivers/core/device.c b/drivers/core/device.c
index 6e26b64fb8..60f8d6700a 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",