summaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2013-04-30 09:43:12 +0200
committerMatt Fleming <matt.fleming@intel.com>2013-04-30 17:03:18 +0200
commit85c90716aae49f05a67c757df7b8c413256103f2 (patch)
treedcb5b0f2e935d9f6042f96f24bcc7f4977142709 /drivers/firmware
parentefi, pstore: Read data from variable store before memcpy() (diff)
downloadlinux-85c90716aae49f05a67c757df7b8c413256103f2.tar.xz
linux-85c90716aae49f05a67c757df7b8c413256103f2.zip
efi: locking fix in efivar_entry_set_safe()
The intent is that if we aren't allowed to block because we're in an NMI or an emergency then we only take the lock if it is uncontended. Part of the problem is the test is reversed so we return -EBUSY if we acquire the lock. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/efi/vars.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/firmware/efi/vars.c b/drivers/firmware/efi/vars.c
index 96d328b21c3e..391c67b182d9 100644
--- a/drivers/firmware/efi/vars.c
+++ b/drivers/firmware/efi/vars.c
@@ -622,10 +622,12 @@ int efivar_entry_set_safe(efi_char16_t *name, efi_guid_t vendor, u32 attributes,
if (!ops->query_variable_store)
return -ENOSYS;
- if (!block && spin_trylock_irqsave(&__efivars->lock, flags))
- return -EBUSY;
- else
+ if (!block) {
+ if (!spin_trylock_irqsave(&__efivars->lock, flags))
+ return -EBUSY;
+ } else {
spin_lock_irqsave(&__efivars->lock, flags);
+ }
status = check_var_size(attributes, size + ucs2_strsize(name, 1024));
if (status != EFI_SUCCESS) {