]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
plat/arm: Add assert for the valid address of dtb information
authorManish V Badarkhe <Manish.Badarkhe@arm.com>
Mon, 29 Jun 2020 06:17:24 +0000 (07:17 +0100)
committerManish V Badarkhe <Manish.Badarkhe@arm.com>
Mon, 29 Jun 2020 13:01:03 +0000 (14:01 +0100)
Added assert in the code to check valid address of dtb information
structure retrieved from fw_config device tree.
This patch fixes coverity defect:360213.

Also, removed conditional calling of "fconf_populate" as "fconf_populate"
function already checks the validity of the device tree address received
and go to panic in case of address is NULL.

Signed-off-by: Manish V Badarkhe <Manish.Badarkhe@arm.com>
Change-Id: Ib83e4e84a95e2456a12c7a2bb3fe70461d882cba

plat/arm/common/arm_bl2_setup.c
plat/arm/common/arm_dyn_cfg.c

index e4a4f8724f0e4c7dcdafe1c2ad6a0dcd67379a20..fd60c2bd3bb7f105349838e15661ffe9f243f58d 100644 (file)
@@ -62,15 +62,13 @@ void arm_bl2_early_platform_setup(uintptr_t fw_config,
        bl2_tzram_layout = *mem_layout;
 
        /* Fill the properties struct with the info from the config dtb */
-       if (fw_config != 0U) {
-               fconf_populate("FW_CONFIG", fw_config);
-       }
+       fconf_populate("FW_CONFIG", fw_config);
 
        /* TB_FW_CONFIG was also loaded by BL1 */
        tb_fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, TB_FW_CONFIG_ID);
-       if (tb_fw_config_info != NULL) {
-               fconf_populate("TB_FW", tb_fw_config_info->config_addr);
-       }
+       assert(tb_fw_config_info != NULL);
+
+       fconf_populate("TB_FW", tb_fw_config_info->config_addr);
 
        /* Initialise the IO layer and register platform IO devices */
        plat_arm_io_setup();
index a28e0ccff250e1fff07c460b50254973778dd9f0..633445badd043f596d3478172e58d5ee3c8736c8 100644 (file)
@@ -93,6 +93,8 @@ void arm_bl1_set_mbedtls_heap(void)
         */
 
        tb_fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, TB_FW_CONFIG_ID);
+       assert(tb_fw_config_info != NULL);
+
        tb_fw_cfg_dtb = tb_fw_config_info->config_addr;
 
        if ((tb_fw_cfg_dtb != 0UL) && (mbedtls_heap_addr != NULL)) {
@@ -134,6 +136,8 @@ void arm_bl1_set_bl2_hash(image_desc_t *image_desc)
        const struct dyn_cfg_dtb_info_t *tb_fw_config_info;
 
        tb_fw_config_info = FCONF_GET_PROPERTY(dyn_cfg, dtb, TB_FW_CONFIG_ID);
+       assert(tb_fw_config_info != NULL);
+
        tb_fw_cfg_dtb = tb_fw_config_info->config_addr;
 
        /*