Skip to content

Commit

Permalink
efivarfs: 'efivarfs_file_write' function reorganization
Browse files Browse the repository at this point in the history
This reorganization removes useless 'bytes' prior assignment and uses
'memdup_user' instead 'kmalloc' + 'copy_from_user'.

Signed-off-by: Geyslan G. Bem <geyslan@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
  • Loading branch information
geyslan authored and Matt Fleming committed Mar 4, 2014
1 parent 0f8093a commit aca32b5
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions fs/efivarfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static ssize_t efivarfs_file_write(struct file *file,
u32 attributes;
struct inode *inode = file->f_mapping->host;
unsigned long datasize = count - sizeof(attributes);
ssize_t bytes = 0;
ssize_t bytes;
bool set = false;

if (count < sizeof(attributes))
Expand All @@ -33,14 +33,9 @@ static ssize_t efivarfs_file_write(struct file *file,
if (attributes & ~(EFI_VARIABLE_MASK))
return -EINVAL;

data = kmalloc(datasize, GFP_KERNEL);
if (!data)
return -ENOMEM;

if (copy_from_user(data, userbuf + sizeof(attributes), datasize)) {
bytes = -EFAULT;
goto out;
}
data = memdup_user(userbuf + sizeof(attributes), datasize);
if (IS_ERR(data))
return PTR_ERR(data);

bytes = efivar_entry_set_get_size(var, attributes, &datasize,
data, &set);
Expand Down

0 comments on commit aca32b5

Please sign in to comment.