]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
dm: core: fix no null pointer detection in ofnode_get_addr_size_index()
authorChen Guanqiao <chenguanqiao@kuaishou.com>
Mon, 12 Jul 2021 07:40:20 +0000 (15:40 +0800)
committerSimon Glass <sjg@chromium.org>
Wed, 21 Jul 2021 16:27:35 +0000 (10:27 -0600)
Fixed a defect of a null pointer being discovered by Coverity Scan:
   CID 331544:  Null pointer dereferences  (REVERSE_INULL)
   Null-checking "size" suggests that it may be null, but it has already been
   dereferenced on all paths leading to the check.

Signed-off-by: Chen Guanqiao <chenguanqiao@kuaishou.com>
drivers/core/ofnode.c

index eeeccfb44674f5b58c55d8e10628fdfd9795378c..dda6c76e834d6da67dd129e25025eb3261fb2a22 100644 (file)
@@ -329,7 +329,8 @@ static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
 {
        int na, ns;
 
-       *size = FDT_SIZE_T_NONE;
+       if (size)
+               *size = FDT_SIZE_T_NONE;
 
        if (ofnode_is_np(node)) {
                const __be32 *prop_val;
@@ -340,6 +341,7 @@ static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
                                          &flags);
                if (!prop_val)
                        return FDT_ADDR_T_NONE;
+
                if (size)
                        *size = size64;
 
@@ -359,8 +361,6 @@ static fdt_addr_t __ofnode_get_addr_size_index(ofnode node, int index,
                                                  index, na, ns, size,
                                                  translate);
        }
-
-       return FDT_ADDR_T_NONE;
 }
 
 fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size)