Commit aca32b57 authored by Geyslan G. Bem's avatar Geyslan G. Bem Committed by Matt Fleming

efivarfs: 'efivarfs_file_write' function reorganization

This reorganization removes useless 'bytes' prior assignment and uses
'memdup_user' instead 'kmalloc' + 'copy_from_user'.
Signed-off-by: default avatarGeyslan G. Bem <geyslan@gmail.com>
Signed-off-by: default avatarMatt Fleming <matt.fleming@intel.com>
parent 0f8093a9
...@@ -21,7 +21,7 @@ static ssize_t efivarfs_file_write(struct file *file, ...@@ -21,7 +21,7 @@ static ssize_t efivarfs_file_write(struct file *file,
u32 attributes; u32 attributes;
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
unsigned long datasize = count - sizeof(attributes); unsigned long datasize = count - sizeof(attributes);
ssize_t bytes = 0; ssize_t bytes;
bool set = false; bool set = false;
if (count < sizeof(attributes)) if (count < sizeof(attributes))
...@@ -33,14 +33,9 @@ static ssize_t efivarfs_file_write(struct file *file, ...@@ -33,14 +33,9 @@ static ssize_t efivarfs_file_write(struct file *file,
if (attributes & ~(EFI_VARIABLE_MASK)) if (attributes & ~(EFI_VARIABLE_MASK))
return -EINVAL; return -EINVAL;
data = kmalloc(datasize, GFP_KERNEL); data = memdup_user(userbuf + sizeof(attributes), datasize);
if (!data) if (IS_ERR(data))
return -ENOMEM; return PTR_ERR(data);
if (copy_from_user(data, userbuf + sizeof(attributes), datasize)) {
bytes = -EFAULT;
goto out;
}
bytes = efivar_entry_set_get_size(var, attributes, &datasize, bytes = efivar_entry_set_get_size(var, attributes, &datasize,
data, &set); data, &set);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment