TF-A: Fix BL2 bug in dynamic configuration initialisation

This patch fixes the bug in BL2 dynamic configuration initialisation
which prevents loading NT_FW_CONFIG image (ref. GENFW-3471).
It also adds parentheses around 'if' statement conditions to fix
Coverity defect.

Change-Id: I353566c29b84341887e13bf8098a4fedfc4e00ff
Signed-off-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
diff --git a/plat/arm/common/arm_dyn_cfg.c b/plat/arm/common/arm_dyn_cfg.c
index aafb190..e6c5a73 100644
--- a/plat/arm/common/arm_dyn_cfg.c
+++ b/plat/arm/common/arm_dyn_cfg.c
@@ -243,7 +243,8 @@
 
 #ifdef	BL31_BASE
 			/* Ensure the configs don't overlap with BL31 */
-			if ((image_base > BL31_BASE) || ((image_base + image_size) > BL31_BASE))
+			if ((image_base >= BL31_BASE) &&
+			    (image_base <= BL31_LIMIT))
 				continue;
 #endif
 			/* Ensure the configs are loaded in a valid address */
@@ -254,7 +255,8 @@
 			 * If BL32 is present, ensure that the configs don't
 			 * overlap with it.
 			 */
-			if (image_base >= BL32_BASE && image_base <= BL32_LIMIT)
+			if ((image_base >= BL32_BASE) &&
+			    (image_base <= BL32_LIMIT))
 				continue;
 #endif
 		}
@@ -263,7 +265,10 @@
 		cfg_mem_params->image_info.image_base = (uintptr_t)image_base;
 		cfg_mem_params->image_info.image_max_size = image_size;
 
-		/* Remove the IMAGE_ATTRIB_SKIP_LOADING attribute from HW_CONFIG node */
+		/*
+		 * Remove the IMAGE_ATTRIB_SKIP_LOADING attribute from
+		 * HW_CONFIG or FW_CONFIG nodes
+		 */
 		cfg_mem_params->image_info.h.attr &= ~IMAGE_ATTRIB_SKIP_LOADING;
 	}