diff options
author | Geyslan G. Bem <geyslan@gmail.com> | 2013-10-30 14:57:41 -0400 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2014-03-04 11:16:16 -0500 |
commit | aca32b5768bb314f5f3f42e26822424468412f5a (patch) | |
tree | 920a5e605f3fe2c7ad77249ae655529dfaa3ad93 /fs/efivarfs | |
parent | 0f8093a92da77afe24fd258a5a1037bb2b97a870 (diff) |
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: Geyslan G. Bem <geyslan@gmail.com>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'fs/efivarfs')
-rw-r--r-- | fs/efivarfs/file.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/fs/efivarfs/file.c b/fs/efivarfs/file.c index 8dd524f32284..cdb2971192a5 100644 --- a/fs/efivarfs/file.c +++ b/fs/efivarfs/file.c | |||
@@ -21,7 +21,7 @@ static ssize_t efivarfs_file_write(struct file *file, | |||
21 | u32 attributes; | 21 | u32 attributes; |
22 | struct inode *inode = file->f_mapping->host; | 22 | struct inode *inode = file->f_mapping->host; |
23 | unsigned long datasize = count - sizeof(attributes); | 23 | unsigned long datasize = count - sizeof(attributes); |
24 | ssize_t bytes = 0; | 24 | ssize_t bytes; |
25 | bool set = false; | 25 | bool set = false; |
26 | 26 | ||
27 | if (count < sizeof(attributes)) | 27 | if (count < sizeof(attributes)) |
@@ -33,14 +33,9 @@ static ssize_t efivarfs_file_write(struct file *file, | |||
33 | if (attributes & ~(EFI_VARIABLE_MASK)) | 33 | if (attributes & ~(EFI_VARIABLE_MASK)) |
34 | return -EINVAL; | 34 | return -EINVAL; |
35 | 35 | ||
36 | data = kmalloc(datasize, GFP_KERNEL); | 36 | data = memdup_user(userbuf + sizeof(attributes), datasize); |
37 | if (!data) | 37 | if (IS_ERR(data)) |
38 | return -ENOMEM; | 38 | return PTR_ERR(data); |
39 | |||
40 | if (copy_from_user(data, userbuf + sizeof(attributes), datasize)) { | ||
41 | bytes = -EFAULT; | ||
42 | goto out; | ||
43 | } | ||
44 | 39 | ||
45 | bytes = efivar_entry_set_get_size(var, attributes, &datasize, | 40 | bytes = efivar_entry_set_get_size(var, attributes, &datasize, |
46 | data, &set); | 41 | data, &set); |