mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
efi: vars: Use locking version to iterate over efivars linked lists
Both efivars and efivarfs uses __efivar_entry_iter() to go over the linked list that shadows the list of EFI variables held by the firmware, but fail to call the begin/end helpers that are documented as a prerequisite. So switch to the proper version, which is efivar_entry_iter(). Given that in both cases, efivar_entry_remove() is invoked with the lock held already, don't take the lock there anymore. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
parent
859748255b
commit
3a75f9f2f9
@ -602,10 +602,7 @@ static int efivars_sysfs_callback(efi_char16_t *name, efi_guid_t vendor,
|
||||
|
||||
static int efivar_sysfs_destroy(struct efivar_entry *entry, void *data)
|
||||
{
|
||||
int err = efivar_entry_remove(entry);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
efivar_entry_remove(entry);
|
||||
efivar_unregister(entry);
|
||||
return 0;
|
||||
}
|
||||
@ -615,8 +612,7 @@ static void efivars_sysfs_exit(void)
|
||||
/* Remove all entries and destroy */
|
||||
int err;
|
||||
|
||||
err = __efivar_entry_iter(efivar_sysfs_destroy, &efivar_sysfs_list,
|
||||
NULL, NULL);
|
||||
err = efivar_entry_iter(efivar_sysfs_destroy, &efivar_sysfs_list, NULL);
|
||||
if (err) {
|
||||
pr_err("efivars: Failed to destroy sysfs entries\n");
|
||||
return;
|
||||
|
@ -523,17 +523,10 @@ EXPORT_SYMBOL_GPL(__efivar_entry_add);
|
||||
/**
|
||||
* efivar_entry_remove - remove entry from variable list
|
||||
* @entry: entry to remove from list
|
||||
*
|
||||
* Returns 0 on success, or a kernel error code on failure.
|
||||
*/
|
||||
int efivar_entry_remove(struct efivar_entry *entry)
|
||||
void efivar_entry_remove(struct efivar_entry *entry)
|
||||
{
|
||||
if (down_interruptible(&efivars_lock))
|
||||
return -EINTR;
|
||||
list_del(&entry->list);
|
||||
up(&efivars_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(efivar_entry_remove);
|
||||
|
||||
|
@ -180,10 +180,7 @@ fail:
|
||||
|
||||
static int efivarfs_destroy(struct efivar_entry *entry, void *data)
|
||||
{
|
||||
int err = efivar_entry_remove(entry);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
efivar_entry_remove(entry);
|
||||
kfree(entry);
|
||||
return 0;
|
||||
}
|
||||
@ -219,7 +216,7 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc)
|
||||
|
||||
err = efivar_init(efivarfs_callback, (void *)sb, true, &efivarfs_list);
|
||||
if (err)
|
||||
__efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL, NULL);
|
||||
efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL);
|
||||
|
||||
return err;
|
||||
}
|
||||
@ -244,7 +241,7 @@ static void efivarfs_kill_sb(struct super_block *sb)
|
||||
kill_litter_super(sb);
|
||||
|
||||
/* Remove all entries and destroy */
|
||||
__efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL, NULL);
|
||||
efivar_entry_iter(efivarfs_destroy, &efivarfs_list, NULL);
|
||||
}
|
||||
|
||||
static struct file_system_type efivarfs_type = {
|
||||
|
@ -1063,7 +1063,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
|
||||
|
||||
int efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
|
||||
void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
|
||||
int efivar_entry_remove(struct efivar_entry *entry);
|
||||
void efivar_entry_remove(struct efivar_entry *entry);
|
||||
|
||||
int __efivar_entry_delete(struct efivar_entry *entry);
|
||||
int efivar_entry_delete(struct efivar_entry *entry);
|
||||
|
Loading…
Reference in New Issue
Block a user