]> Pileus Git - ~andy/linux/commitdiff
efi: locking fix in efivar_entry_set_safe()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 30 Apr 2013 07:43:12 +0000 (10:43 +0300)
committerMatt Fleming <matt.fleming@intel.com>
Tue, 30 Apr 2013 15:03:18 +0000 (16:03 +0100)
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>
drivers/firmware/efi/vars.c

index 96d328b21c3e408918bdfb779dc11c6eb7574abb..391c67b182d9b282681890cd04b98c0183023abc 100644 (file)
@@ -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) {