Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c475594d authored by Mike Waychison's avatar Mike Waychison Committed by Tony Luck
Browse files

efivars: Use string functions in pstore_write



Instead of open-coding the string operations for comparing the prefix of
the variable names, use the provided utf16_* string functions.

This patch also changes the calls to efi.set_variable to
efivars->ops->set_variable so that the right function gets called in the
case of gsmi (which doesn't have a valid efi structure).

As well, make sure that we only consider variables with the right vendor
string.

Signed-off-by: default avatarMike Waychison <mikew@google.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent 828aa1f0
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -512,18 +512,20 @@ static u64 efi_pstore_write(enum pstore_type_id type, unsigned int part,
	list_for_each_entry(entry, &efivars->list, list) {
		get_var_data_locked(efivars, &entry->var);

		for (i = 0; i < DUMP_NAME_LEN; i++) {
			if (efi_name[i] == 0) {
		if (efi_guidcmp(entry->var.VendorGuid, vendor))
			continue;
		if (utf16_strncmp(entry->var.VariableName, efi_name,
				  utf16_strlen(efi_name)))
			continue;
		/* Needs to be a prefix */
		if (entry->var.VariableName[utf16_strlen(efi_name)] == 0)
			continue;

		/* found */
		found = entry;
				efivars->ops->set_variable(entry->var.VariableName,
							   &entry->var.VendorGuid,
		efivars->ops->set_variable(entry->var.VariableName, &entry->var.VendorGuid,
					   EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
					   0, NULL);
				break;
			} else if (efi_name[i] != entry->var.VariableName[i]) {
				break;
			}
		}
	}

	if (found)