Prevent using empty response in secure_storage_client_get_info

Fix condition which validates response length in
secure_storage_client_get_info.

Signed-off-by: Imre Kis <imre.kis@arm.com>
Change-Id: Iaeb6082023d2876df38691acb97cf6966cdc9c3d
diff --git a/components/service/secure_storage/backend/secure_storage_client/secure_storage_client.c b/components/service/secure_storage/backend/secure_storage_client/secure_storage_client.c
index cd7c147..fed2fe7 100644
--- a/components/service/secure_storage/backend/secure_storage_client/secure_storage_client.c
+++ b/components/service/secure_storage/backend/secure_storage_client/secure_storage_client.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
+ * Copyright (c) 2020-2022, Arm Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -178,11 +178,22 @@
 			/* RPC failure */
 			psa_status = PSA_ERROR_GENERIC_ERROR;
 		} else {
-			if (response_length && response_length != sizeof(*response_desc)) {
-				psa_status = PSA_ERROR_GENERIC_ERROR;
-			}
-			else {
+			if (response_length == sizeof(*response_desc)) {
+				/* Response length matches the expected size */
 				psa_status = opstatus;
+			} else if (!response_length) {
+				/*
+				 * In case of an empty response use opstatus but
+				 * fall back to PSA_ERROR_GENERIC_ERROR if opstatus
+				 * contains PSA_SUCCESS as this is an invalid case.
+				 */
+				if (opstatus != PSA_SUCCESS)
+					psa_status = opstatus;
+				else
+					psa_status = PSA_ERROR_GENERIC_ERROR;
+			} else {
+				/* Invalid length */
+				psa_status = PSA_ERROR_GENERIC_ERROR;
 			}
 		}