diff options
author | Mingyang Sun <mingyang.sun@arm.com> | 2021-05-13 12:12:05 +0800 |
---|---|---|
committer | Mingyang Sun <mingyang.sun@arm.com> | 2021-05-13 16:56:04 +0800 |
commit | 1881ef1a5e3e9de6e88dfdbe733b0155a4a202e8 (patch) | |
tree | 32cf4056a1ce5fdcc32e486f15392a94c638057a /secure_fw | |
parent | 2b35266737ee087685aee6baf76e6c49804d1eb8 (diff) | |
download | trusted-firmware-m-1881ef1a5e3e9de6e88dfdbe733b0155a4a202e8.tar.gz |
SPM: Fix service allocation logic
Some partitions do not have services. An error will occur when
service pool is full and call the allocation API with argument
0 again.
Change-Id: Ia088f0577dfc1a4aa7964f190997c0c4c8c99fe0
Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
Diffstat (limited to 'secure_fw')
-rw-r--r-- | secure_fw/spm/cmsis_psa/spm_ipc.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c index 9f4322e8d2..1e547efec5 100644 --- a/secure_fw/spm/cmsis_psa/spm_ipc.c +++ b/secure_fw/spm/cmsis_psa/spm_ipc.c @@ -668,7 +668,8 @@ static struct service_t *tfm_allocate_service(uint32_t service_count) struct service_t *p_service_allocated = NULL; uint32_t num_of_services = sizeof(g_services) / sizeof(struct service_t); - if ((service_count > num_of_services) || + if ((service_count == 0) || + (service_count > num_of_services) || (service_pool_pos >= num_of_services) || (service_pool_pos + service_count > num_of_services)) { return NULL; @@ -736,9 +737,13 @@ uint32_t tfm_spm_init(void) if (!partition) { tfm_core_panic(); } - service = tfm_allocate_service(p_cmninf->nservices); - if (!service) { - tfm_core_panic(); + if (p_cmninf->nservices) { + service = tfm_allocate_service(p_cmninf->nservices); + if (!service) { + tfm_core_panic(); + } + } else { + service = NULL; } partition->p_static = p_cmninf; |