Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

efi: vars: Drop __efivar_entry_iter() helper which is no longer used

__efivar_entry_iter() uses a list iterator in a dubious way, i.e., it
assumes that the iteration variable always points to an object of the
appropriate type, even if the list traversal exhausts the list
completely, in which case it will point somewhere in the vicinity of the
list's anchor instead.

Fortunately, we no longer use this function so we can just get rid of it
entirely.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

+7 -57
+7 -54
drivers/firmware/efi/vars.c
··· 1035 1035 EXPORT_SYMBOL_GPL(efivar_entry_iter_end); 1036 1036 1037 1037 /** 1038 - * __efivar_entry_iter - iterate over variable list 1039 - * @func: callback function 1040 - * @head: head of the variable list 1041 - * @data: function-specific data to pass to callback 1042 - * @prev: entry to begin iterating from 1043 - * 1044 - * Iterate over the list of EFI variables and call @func with every 1045 - * entry on the list. It is safe for @func to remove entries in the 1046 - * list via efivar_entry_delete(). 1047 - * 1048 - * You MUST call efivar_entry_iter_begin() before this function, and 1049 - * efivar_entry_iter_end() afterwards. 1050 - * 1051 - * It is possible to begin iteration from an arbitrary entry within 1052 - * the list by passing @prev. @prev is updated on return to point to 1053 - * the last entry passed to @func. To begin iterating from the 1054 - * beginning of the list @prev must be %NULL. 1055 - * 1056 - * The restrictions for @func are the same as documented for 1057 - * efivar_entry_iter(). 1058 - */ 1059 - int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *), 1060 - struct list_head *head, void *data, 1061 - struct efivar_entry **prev) 1062 - { 1063 - struct efivar_entry *entry, *n; 1064 - int err = 0; 1065 - 1066 - if (!prev || !*prev) { 1067 - list_for_each_entry_safe(entry, n, head, list) { 1068 - err = func(entry, data); 1069 - if (err) 1070 - break; 1071 - } 1072 - 1073 - if (prev) 1074 - *prev = entry; 1075 - 1076 - return err; 1077 - } 1078 - 1079 - 1080 - list_for_each_entry_safe_continue((*prev), n, head, list) { 1081 - err = func(*prev, data); 1082 - if (err) 1083 - break; 1084 - } 1085 - 1086 - return err; 1087 - } 1088 - EXPORT_SYMBOL_GPL(__efivar_entry_iter); 1089 - 1090 - /** 1091 1038 * efivar_entry_iter - iterate over variable list 1092 1039 * @func: callback function 1093 1040 * @head: head of variable list ··· 1051 1104 int efivar_entry_iter(int (*func)(struct efivar_entry *, void *), 1052 1105 struct list_head *head, void *data) 1053 1106 { 1107 + struct efivar_entry *entry, *n; 1054 1108 int err = 0; 1055 1109 1056 1110 err = efivar_entry_iter_begin(); 1057 1111 if (err) 1058 1112 return err; 1059 - err = __efivar_entry_iter(func, head, data, NULL); 1113 + 1114 + list_for_each_entry_safe(entry, n, head, list) { 1115 + err = func(entry, data); 1116 + if (err) 1117 + break; 1118 + } 1060 1119 efivar_entry_iter_end(); 1061 1120 1062 1121 return err;
-3
include/linux/efi.h
··· 1083 1083 int efivar_entry_iter_begin(void); 1084 1084 void efivar_entry_iter_end(void); 1085 1085 1086 - int __efivar_entry_iter(int (*func)(struct efivar_entry *, void *), 1087 - struct list_head *head, void *data, 1088 - struct efivar_entry **prev); 1089 1086 int efivar_entry_iter(int (*func)(struct efivar_entry *, void *), 1090 1087 struct list_head *head, void *data); 1091 1088