Skip to content

Commit a58e954

Browse files
James Bottomleyardbiesheuvel
authored andcommitted
efivarfs: remove unused efivarfs_list
Remove all function helpers and mentions of the efivarfs_list now that all consumers of the list have been removed and entry management goes exclusively through the inode. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent fddca52 commit a58e954

File tree

4 files changed

+21
-116
lines changed

4 files changed

+21
-116
lines changed

fs/efivarfs/inode.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ static bool efivarfs_valid_name(const char *str, int len)
7777
static int efivarfs_create(struct mnt_idmap *idmap, struct inode *dir,
7878
struct dentry *dentry, umode_t mode, bool excl)
7979
{
80-
struct efivarfs_fs_info *info = dir->i_sb->s_fs_info;
8180
struct inode *inode = NULL;
8281
struct efivar_entry *var;
8382
int namelen, i = 0, err = 0;
@@ -92,21 +91,17 @@ static int efivarfs_create(struct mnt_idmap *idmap, struct inode *dir,
9291

9392
err = guid_parse(dentry->d_name.name + namelen + 1, &vendor);
9493
if (err)
95-
goto out;
96-
if (guid_equal(&vendor, &LINUX_EFI_RANDOM_SEED_TABLE_GUID)) {
97-
err = -EPERM;
98-
goto out;
99-
}
94+
return err;
95+
if (guid_equal(&vendor, &LINUX_EFI_RANDOM_SEED_TABLE_GUID))
96+
return -EPERM;
10097

10198
if (efivar_variable_is_removable(vendor,
10299
dentry->d_name.name, namelen))
103100
is_removable = true;
104101

105102
inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0, is_removable);
106-
if (!inode) {
107-
err = -ENOMEM;
108-
goto out;
109-
}
103+
if (!inode)
104+
return -ENOMEM;
110105
var = efivar_entry(inode);
111106

112107
var->var.VendorGuid = vendor;
@@ -118,17 +113,10 @@ static int efivarfs_create(struct mnt_idmap *idmap, struct inode *dir,
118113

119114
inode->i_private = var;
120115

121-
err = efivar_entry_add(var, &info->efivarfs_list);
122-
if (err)
123-
goto out;
124-
125116
d_instantiate(dentry, inode);
126117
dget(dentry);
127-
out:
128-
if (err && inode)
129-
iput(inode);
130118

131-
return err;
119+
return 0;
132120
}
133121

134122
static int efivarfs_unlink(struct inode *dir, struct dentry *dentry)

fs/efivarfs/internal.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#ifndef EFIVAR_FS_INTERNAL_H
77
#define EFIVAR_FS_INTERNAL_H
88

9-
#include <linux/list.h>
109
#include <linux/efi.h>
1110

1211
struct efivarfs_mount_opts {
@@ -16,7 +15,6 @@ struct efivarfs_mount_opts {
1615

1716
struct efivarfs_fs_info {
1817
struct efivarfs_mount_opts mount_opts;
19-
struct list_head efivarfs_list;
2018
struct super_block *sb;
2119
struct notifier_block nb;
2220
};
@@ -28,7 +26,6 @@ struct efi_variable {
2826

2927
struct efivar_entry {
3028
struct efi_variable var;
31-
struct list_head list;
3229
struct inode vfs_inode;
3330
};
3431

@@ -37,12 +34,9 @@ static inline struct efivar_entry *efivar_entry(struct inode *inode)
3734
return container_of(inode, struct efivar_entry, vfs_inode);
3835
}
3936

40-
int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
41-
struct list_head *),
42-
void *data, struct list_head *head);
37+
int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
38+
void *data);
4339

44-
int efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
45-
void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head);
4640
int efivar_entry_delete(struct efivar_entry *entry);
4741

4842
int efivar_entry_size(struct efivar_entry *entry, unsigned long *size);
@@ -53,8 +47,6 @@ int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
5347
int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
5448
unsigned long *size, void *data, bool *set);
5549

56-
int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
57-
struct list_head *head, void *data);
5850

5951
bool efivar_validate(efi_guid_t vendor, efi_char16_t *var_name, u8 *data,
6052
unsigned long data_size);

fs/efivarfs/super.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ static void efivarfs_free_inode(struct inode *inode)
5555
{
5656
struct efivar_entry *entry = efivar_entry(inode);
5757

58-
if (inode->i_private)
59-
list_del(&entry->list);
6058
kfree(entry);
6159
}
6260

@@ -228,8 +226,7 @@ bool efivarfs_variable_is_present(efi_char16_t *variable_name,
228226
}
229227

230228
static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
231-
unsigned long name_size, void *data,
232-
struct list_head *list)
229+
unsigned long name_size, void *data)
233230
{
234231
struct super_block *sb = (struct super_block *)data;
235232
struct efivar_entry *entry;
@@ -271,7 +268,6 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
271268
}
272269

273270
__efivar_entry_get(entry, NULL, &size, NULL);
274-
__efivar_entry_add(entry, list);
275271

276272
/* copied by the above to local storage in the dentry. */
277273
kfree(name);
@@ -361,7 +357,7 @@ static int efivarfs_fill_super(struct super_block *sb, struct fs_context *fc)
361357
if (err)
362358
return err;
363359

364-
return efivar_init(efivarfs_callback, sb, &sfi->efivarfs_list);
360+
return efivar_init(efivarfs_callback, sb);
365361
}
366362

367363
static int efivarfs_get_tree(struct fs_context *fc)
@@ -396,8 +392,6 @@ static int efivarfs_init_fs_context(struct fs_context *fc)
396392
if (!sfi)
397393
return -ENOMEM;
398394

399-
INIT_LIST_HEAD(&sfi->efivarfs_list);
400-
401395
sfi->mount_opts.uid = GLOBAL_ROOT_UID;
402396
sfi->mount_opts.gid = GLOBAL_ROOT_GID;
403397

@@ -413,8 +407,6 @@ static void efivarfs_kill_sb(struct super_block *sb)
413407
blocking_notifier_chain_unregister(&efivar_ops_nh, &sfi->nb);
414408
kill_litter_super(sb);
415409

416-
/* Remove all entries and destroy */
417-
WARN_ON(!list_empty(&sfi->efivarfs_list));
418410
kfree(sfi);
419411
}
420412

fs/efivarfs/vars.c

Lines changed: 11 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,14 @@ static void dup_variable_bug(efi_char16_t *str16, efi_guid_t *vendor_guid,
364364
* efivar_init - build the initial list of EFI variables
365365
* @func: callback function to invoke for every variable
366366
* @data: function-specific data to pass to @func
367-
* @head: initialised head of variable list
368367
*
369368
* Get every EFI variable from the firmware and invoke @func. @func
370-
* should call efivar_entry_add() to build the list of variables.
369+
* should populate the initial dentry and inode tree.
371370
*
372371
* Returns 0 on success, or a kernel error code on failure.
373372
*/
374-
int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
375-
struct list_head *),
376-
void *data, struct list_head *head)
373+
int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *),
374+
void *data)
377375
{
378376
unsigned long variable_name_size = 512;
379377
efi_char16_t *variable_name;
@@ -424,7 +422,7 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
424422
status = EFI_NOT_FOUND;
425423
} else {
426424
err = func(variable_name, vendor_guid,
427-
variable_name_size, data, head);
425+
variable_name_size, data);
428426
if (err)
429427
status = EFI_NOT_FOUND;
430428
}
@@ -456,42 +454,12 @@ int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *,
456454
}
457455

458456
/**
459-
* efivar_entry_add - add entry to variable list
460-
* @entry: entry to add to list
461-
* @head: list head
462-
*
463-
* Returns 0 on success, or a kernel error code on failure.
464-
*/
465-
int efivar_entry_add(struct efivar_entry *entry, struct list_head *head)
466-
{
467-
int err;
468-
469-
err = efivar_lock();
470-
if (err)
471-
return err;
472-
list_add(&entry->list, head);
473-
efivar_unlock();
474-
475-
return 0;
476-
}
477-
478-
/**
479-
* __efivar_entry_add - add entry to variable list
480-
* @entry: entry to add to list
481-
* @head: list head
482-
*/
483-
void __efivar_entry_add(struct efivar_entry *entry, struct list_head *head)
484-
{
485-
list_add(&entry->list, head);
486-
}
487-
488-
/**
489-
* efivar_entry_delete - delete variable and remove entry from list
457+
* efivar_entry_delete - delete variable
490458
* @entry: entry containing variable to delete
491459
*
492-
* Delete the variable from the firmware and remove @entry from the
493-
* variable list. It is the caller's responsibility to free @entry
494-
* once we return.
460+
* Delete the variable from the firmware. It is the caller's
461+
* responsibility to free @entry (by deleting the dentry/inode) once
462+
* we return.
495463
*
496464
* Returns 0 on success, -EINTR if we can't grab the semaphore,
497465
* converted EFI status code if set_variable() fails.
@@ -605,7 +573,7 @@ int efivar_entry_get(struct efivar_entry *entry, u32 *attributes,
605573
* get_variable() fail.
606574
*
607575
* If the EFI variable does not exist when calling set_variable()
608-
* (EFI_NOT_FOUND), @entry is removed from the variable list.
576+
* (EFI_NOT_FOUND).
609577
*/
610578
int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
611579
unsigned long *size, void *data, bool *set)
@@ -621,9 +589,8 @@ int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
621589
return -EINVAL;
622590

623591
/*
624-
* The lock here protects the get_variable call, the conditional
625-
* set_variable call, and removal of the variable from the efivars
626-
* list (in the case of an authenticated delete).
592+
* The lock here protects the get_variable call and the
593+
* conditional set_variable call
627594
*/
628595
err = efivar_lock();
629596
if (err)
@@ -661,37 +628,3 @@ int efivar_entry_set_get_size(struct efivar_entry *entry, u32 attributes,
661628
return err;
662629

663630
}
664-
665-
/**
666-
* efivar_entry_iter - iterate over variable list
667-
* @func: callback function
668-
* @head: head of variable list
669-
* @data: function-specific data to pass to callback
670-
*
671-
* Iterate over the list of EFI variables and call @func with every
672-
* entry on the list. It is safe for @func to remove entries in the
673-
* list via efivar_entry_delete() while iterating.
674-
*
675-
* Some notes for the callback function:
676-
* - a non-zero return value indicates an error and terminates the loop
677-
* - @func is called from atomic context
678-
*/
679-
int efivar_entry_iter(int (*func)(struct efivar_entry *, void *),
680-
struct list_head *head, void *data)
681-
{
682-
struct efivar_entry *entry, *n;
683-
int err = 0;
684-
685-
err = efivar_lock();
686-
if (err)
687-
return err;
688-
689-
list_for_each_entry_safe(entry, n, head, list) {
690-
err = func(entry, data);
691-
if (err)
692-
break;
693-
}
694-
efivar_unlock();
695-
696-
return err;
697-
}

0 commit comments

Comments
 (0)