Skip to content

Commit

Permalink
efi: locking fix in efivar_entry_set_safe()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Dan Carpenter authored and Matt Fleming committed Apr 30, 2013
1 parent 8a415b8 commit 85c9071
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions drivers/firmware/efi/vars.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 85c9071

Please sign in to comment.