Fix smm_variable getNextVariable invalid parameter handling

The case where a non-empty variable name that doesn't exist
was being reported with a status of EFI_NOT_FOUND. This
error condition should have the status EFI_INVALID_PARAMETER
to allow a client to distinguish between the normal termination
case and the case where a variable name that no longer exists
is passed.

Signed-off-by: Julian Hall <julian.hall@arm.com>
Change-Id: Ia67b5ff25782676a554842365d5c15640ed101da
diff --git a/components/service/smm_variable/backend/variable_index.c b/components/service/smm_variable/backend/variable_index.c
index a8a5575..4abb718 100644
--- a/components/service/smm_variable/backend/variable_index.c
+++ b/components/service/smm_variable/backend/variable_index.c
@@ -153,9 +153,11 @@
 	const struct variable_index *context,
 	const EFI_GUID *guid,
 	size_t name_size,
-	const int16_t *name)
+	const int16_t *name,
+	efi_status_t *status)
 {
 	struct variable_info *result = NULL;
+	*status = EFI_NOT_FOUND;
 
 	if (name_size >= sizeof(int16_t)) {
 
@@ -178,12 +180,18 @@
 						context->entries[pos].info.is_variable_set) {
 
 						result = &context->entries[pos].info;
+						*status = EFI_SUCCESS;
 						break;
 					}
 
 					++pos;
 				}
 			}
+			else {
+
+				/* A non-empty name was provided but it wasn't found */
+				*status = EFI_INVALID_PARAMETER;
+			}
 		}
 		else {
 
@@ -196,6 +204,7 @@
 					context->entries[pos].info.is_variable_set) {
 
 					result = &context->entries[pos].info;
+					*status = EFI_SUCCESS;
 					break;
 				}