summaryrefslogtreecommitdiff
path: root/bl32
diff options
context:
space:
mode:
authorShruti Gupta <shruti.gupta@arm.com>2022-08-25 14:22:53 +0100
committerShruti Gupta <shruti.gupta@arm.com>2022-12-08 12:30:10 +0000
commit1543d17b9876add1cb89c1f5ffe0e6a129f5809e (patch)
tree7df2a71b0e3ec51131e2b627d766eb00404dcace /bl32
parentdef7590b3e34ff69b297c239cb8948d0bdc9c691 (diff)
downloadarm-trusted-firmware-1543d17b9876add1cb89c1f5ffe0e6a129f5809e.tar.gz
fix(el3-spmc): fix coverity scan warnings
Validate emad descriptor integrity before accessing. Check for NULL pointer access. Signed-off-by: Shruti Gupta <shruti.gupta@arm.com> Change-Id: Id4ff3e5d88be95ca8d067378e344947880ec984b
Diffstat (limited to 'bl32')
-rw-r--r--bl32/tsp/ffa_helpers.c4
-rw-r--r--bl32/tsp/tsp_ffa_main.c7
2 files changed, 7 insertions, 4 deletions
diff --git a/bl32/tsp/ffa_helpers.c b/bl32/tsp/ffa_helpers.c
index 3639c221c..ad70c2b7c 100644
--- a/bl32/tsp/ffa_helpers.c
+++ b/bl32/tsp/ffa_helpers.c
@@ -149,13 +149,15 @@ bool memory_retrieve(struct mailbox *mb,
{
smc_args_t ret;
uint32_t descriptor_size;
- struct ffa_mtd *memory_region = (struct ffa_mtd *)mb->tx_buffer;
+ struct ffa_mtd *memory_region;
if (retrieved == NULL || mb == NULL) {
ERROR("Invalid parameters!\n");
return false;
}
+ memory_region = (struct ffa_mtd *)mb->tx_buffer;
+
/* Clear TX buffer. */
memset(memory_region, 0, PAGE_SIZE);
diff --git a/bl32/tsp/tsp_ffa_main.c b/bl32/tsp/tsp_ffa_main.c
index 53dbd03d5..3cbeb7a94 100644
--- a/bl32/tsp/tsp_ffa_main.c
+++ b/bl32/tsp/tsp_ffa_main.c
@@ -216,10 +216,10 @@ static int test_memory_send(ffa_endpoint_id16_t sender, uint64_t handle,
(uint64_t)composite->address_range_array[i].address,
size, mem_attrs);
- /* Remove mappings created in this transaction. */
- for (i--; i >= 0U; i--) {
+ /* Remove mappings previously created in this transaction. */
+ for (i--; i >= 0; i--) {
ret = mmap_remove_dynamic_region(
- (uint64_t)ptr,
+ (uint64_t)composite->address_range_array[i].address,
composite->address_range_array[i].page_count * PAGE_SIZE);
if (ret != 0) {
@@ -227,6 +227,7 @@ static int test_memory_send(ffa_endpoint_id16_t sender, uint64_t handle,
panic();
}
}
+
return FFA_ERROR_NO_MEMORY;
}