[PATCH 09/17] dm: core: Check uclass_get() return value when dumping

Simon Glass sjg at chromium.org
Sun May 9 00:00:13 CEST 2021


Update dm_dump_drivers() to use the return value from uclass_get() to
check the validity of uc. This is equivalent and should be more attractive
to Coverity.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reported-by: Coverity (CID: 316601)
---

 drivers/core/dump.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/core/dump.c b/drivers/core/dump.c
index f8afea30a93..f2f9cacc56c 100644
--- a/drivers/core/dump.c
+++ b/drivers/core/dump.c
@@ -130,18 +130,19 @@ void dm_dump_drivers(void)
 	struct driver *entry;
 	struct udevice *udev;
 	struct uclass *uc;
+	int ret;
 	int i;
 
 	puts("Driver                    uid uclass               Devices\n");
 	puts("----------------------------------------------------------\n");
 
 	for (entry = d; entry < d + n_ents; entry++) {
-		uclass_get(entry->id, &uc);
+		ret = uclass_get(entry->id, &uc);
 
 		printf("%-25.25s %-3.3d %-20.20s ", entry->name, entry->id,
-		       uc ? uc->uc_drv->name : "<no uclass>");
+		       !ret ? uc->uc_drv->name : "<no uclass>");
 
-		if (!uc) {
+		if (ret) {
 			puts("\n");
 			continue;
 		}
-- 
2.31.1.607.g51e8a6a459-goog



More information about the U-Boot mailing list