mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Garrett <mjg@redhat.com>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, mikew@google.com, tony.luck@intel.com
Subject: [PATCH 8/9] efivars: Use string functions in pstore_write
Date: Mon, 18 Jul 2011 16:30:32 -0400	[thread overview]
Message-ID: <1311021033-7483-9-git-send-email-mjg@redhat.com> (raw)
In-Reply-To: <1311021033-7483-1-git-send-email-mjg@redhat.com>

From: Mike Waychison <mikew@google.com>

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: Mike Waychison <mikew@google.com>
---
 drivers/firmware/efivars.c |   26 ++++++++++++++------------
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 15b9a01..563492e 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -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) {
-				found = entry;
-				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 (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,
+					   EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+					   0, NULL);
 	}
 
 	if (found)
-- 
1.7.6


  parent reply	other threads:[~2011-07-18 20:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18 20:30 Add an EFI pstore backend Matthew Garrett
2011-07-18 20:30 ` [PATCH 1/9] pstore: Extend API Matthew Garrett
2011-07-18 20:30 ` [PATCH 2/9] pstore: Add extra context for writes and erases Matthew Garrett
2011-07-18 20:30 ` [PATCH 3/9] pstore: Make "part" unsigned Matthew Garrett
2011-07-18 20:30 ` [PATCH 4/9] pstore: Allow the user to explicitly choose a backend Matthew Garrett
2011-07-18 20:58   ` Tony Luck
2011-07-18 21:00     ` Matthew Garrett
2011-07-18 21:08       ` Tony Luck
2011-07-20 13:27   ` Konrad Rzeszutek Wilk
2011-07-20 14:29     ` Luck, Tony
2011-07-18 20:30 ` [PATCH 5/9] efi: Add support for using efivars as a pstore backend Matthew Garrett
2011-07-18 20:30 ` [PATCH 6/9] efivars: String functions Matthew Garrett
2011-07-18 20:30 ` [PATCH 7/9] efivars: introduce utf16_strncmp Matthew Garrett
2011-07-18 20:30 ` Matthew Garrett [this message]
2011-07-18 20:30 ` [PATCH 9/9] efivars: Introduce PSTORE_EFI_ATTRIBUTES Matthew Garrett

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1311021033-7483-9-git-send-email-mjg@redhat.com \
    --to=mjg@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikew@google.com \
    --cc=tony.luck@intel.com \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®