SPM: Correct 'invalid parameter' error handling
- 'Invalid parameter' is regarded as 'programmer error' instead of
return 'PSA_ERROR_INVALID_ARGUMENT'.
- 'Programmer error' should be handled inside SPM instead of interface,
as SPM needs to decide the error handling based on the caller
attribute.
- Keep the parameters range check inside the interface to give an explicit
hint.
- Correct 'type' casting to avoid lose sign bit.
Change-Id: I35a5b70b5dc1ea7072c45f0ebac0630f65edfa00
Signed-off-by: Shawn Shan <Shawn.Shan@arm.com>
diff --git a/interface/src/tfm_psa_ns_api.c b/interface/src/tfm_psa_ns_api.c
index 9d60a11..751216d 100644
--- a/interface/src/tfm_psa_ns_api.c
+++ b/interface/src/tfm_psa_ns_api.c
@@ -50,10 +50,9 @@
{
if ((type > INT16_MAX) ||
(type < INT16_MIN) ||
- (in_len > PSA_MAX_IOVEC) ||
- (out_len > PSA_MAX_IOVEC) ||
- ((in_len + out_len) > PSA_MAX_IOVEC)) {
- return PSA_ERROR_INVALID_ARGUMENT;
+ (in_len > UINT8_MAX) ||
+ (out_len > UINT8_MAX)) {
+ return PSA_ERROR_PROGRAMMER_ERROR;
}
return tfm_ns_interface_dispatch(