On 03/26/2013 11:56 AM, Matthew Garrett wrote:
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 7acafb8..731ac7b 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -436,9 +436,12 @@ static efi_status_t
check_var_size_locked(struct efivars *efivars, u32 attributes,
unsigned long size)
{
- u64 storage_size, remaining_size, max_size;
+ u64 storage_size, remaining_size, max_size, active_available;
+ struct efivar_entry *entry;
+ struct efi_variable *var;
efi_status_t status;
const struct efivar_operations *fops = efivars->ops;
+ unsigned long active_size = 0;
if (!efivars->ops->query_variable_info)
return EFI_UNSUPPORTED;
@@ -449,8 +452,16 @@ check_var_size_locked(struct efivars *efivars, u32
attributes,
if (status != EFI_SUCCESS)
return status;
+ list_for_each_entry(entry, &efivars->list, list) {
+ var = &entry->var;
+ get_var_data_locked(efivars, var);
Check the return value here? Like for an empty efivarfs file,
it would return EFI_NOT_FOUND and active_size += 1024.
+ active_size += var->DataSize;
+ }
+
+ active_available = storage_size - active_size;
+
if (!storage_size || size > remaining_size || size > max_size ||
- (remaining_size - size) < (storage_size / 2))
+ (active_available - size) < (storage_size / 2))
return EFI_OUT_OF_RESOURCES;
return status;
--
To unsubscribe from this list: send the line "unsubscribe linux-efi" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html