]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: Check uclass_get() return value when dumping
authorSimon Glass <sjg@chromium.org>
Fri, 14 May 2021 01:39:24 +0000 (19:39 -0600)
committerTom Rini <trini@konsulko.com>
Thu, 15 Jul 2021 22:42:05 +0000 (18:42 -0400)
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@chromium.org>
Reported-by: Coverity (CID: 316601)
drivers/core/dump.c

index f8afea30a9351cd83243e221bdb2d4dfb84a967a..f2f9cacc56c4d8af84645a849cc32800acede786 100644 (file)
@@ -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;
                }