efivarfs: 'efivarfs_file_write' function reorganization
Subsystems (2)
PATCH v2 1/1 efivarfs: 'efivarfs_file_write' function reorganization
This reorganization:
Removes useless 'bytes' prior assignment.
Uses 'memdup_user' instead 'kmalloc' + 'copy_from_user'.
Signed-off-by Geyslan G. Bem <[email protected]>
--- fs/efivarfs/file.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
fs/efivarfs/file.c +4 -9
@@ -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);
Signature · 1 line
1.8.4
Quoted 10 lines · Geyslan G. Bem
This reorganization:
Removes useless 'bytes' prior assignment.
Uses '
memdup_user' instead 'kmalloc' + 'copy_from_user'.Signed-off-by Geyslan G. Bem <[email protected]>--- fs/efivarfs/file.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
Thanks, this is what I applied,
---
Quoted 1 line
From
00ad8da13638dba692eaa58b0cba25f3f1a801b1Mon Sep 17 00:00:00 2001
From: "Geyslan G. Bem" <[email protected]>
Date: Wed, 30 Oct 2013 15:57:41 -0300
Subject: [PATCH] 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 <[email protected]>
Signed-off-by Matt Fleming <[email protected]>
--- fs/efivarfs/file.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
fs/efivarfs/file.c +4 -9
@@ -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);
Signature · 4 lines
1.8.1.4 -- Matt Fleming, Intel Open Source Technology Center