summaryrefslogtreecommitdiffstats
path: root/fs/efivarfs
diff options
context:
space:
mode:
authorGeyslan G. Bem <geyslan@gmail.com>2013-10-30 19:57:41 +0100
committerMatt Fleming <matt.fleming@intel.com>2014-03-04 17:16:16 +0100
commitaca32b5768bb314f5f3f42e26822424468412f5a (patch)
tree920a5e605f3fe2c7ad77249ae655529dfaa3ad93 /fs/efivarfs
parentefi: Set feature flags inside feature init functions (diff)
downloadlinux-aca32b5768bb314f5f3f42e26822424468412f5a.tar.xz
linux-aca32b5768bb314f5f3f42e26822424468412f5a.zip
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.c13
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,
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))
@@ -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);