]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
armv8/fsl-lsch3: fdt: Check the pointer returned from call to a function may be NULL
authorAlison Wang <b18965@freescale.com>
Tue, 1 Sep 2015 02:47:27 +0000 (10:47 +0800)
committerYork Sun <yorksun@freescale.com>
Mon, 26 Oct 2015 16:09:55 +0000 (09:09 -0700)
Pointer 'reg' returned from call to function 'fdt_getprop' may be
NULL, will be passed to function and may be dereferenced there by
passing argument 1 to function 'of_read_number'. So check pointer
'reg' first.

Signed-off-by: Alison Wang <alison.wang@freescale.com>
Reviewed-by: York Sun <yorksun@freescale.com>
arch/arm/cpu/armv8/fsl-lsch3/fdt.c

index 567c41927ad7d354374752d43b72bdb9ab6b8f4b..922e8a0d6ebb83b17459c7d1020ddd5d6c97389e 100644 (file)
@@ -33,8 +33,8 @@ void ft_fixup_cpu(void *blob)
        off = fdt_node_offset_by_prop_value(blob, -1, "device_type", "cpu", 4);
        while (off != -FDT_ERR_NOTFOUND) {
                reg = (fdt32_t *)fdt_getprop(blob, off, "reg", 0);
-               core_id = of_read_number(reg, addr_cells);
                if (reg) {
+                       core_id = of_read_number(reg, addr_cells);
                        if (core_id  == 0 || (is_core_online(core_id))) {
                                val = spin_tbl_addr;
                                val += id_to_core(core_id) *