diff options
Diffstat (limited to 'drivers/firmware')
-rw-r--r-- | drivers/firmware/efivars.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c index 58cec627a821..9ac934018bba 100644 --- a/drivers/firmware/efivars.c +++ b/drivers/firmware/efivars.c | |||
@@ -694,6 +694,7 @@ static ssize_t efivarfs_file_write(struct file *file, | |||
694 | struct inode *inode = file->f_mapping->host; | 694 | struct inode *inode = file->f_mapping->host; |
695 | unsigned long datasize = count - sizeof(attributes); | 695 | unsigned long datasize = count - sizeof(attributes); |
696 | unsigned long newdatasize; | 696 | unsigned long newdatasize; |
697 | ssize_t bytes = 0; | ||
697 | 698 | ||
698 | if (count < sizeof(attributes)) | 699 | if (count < sizeof(attributes)) |
699 | return -EINVAL; | 700 | return -EINVAL; |
@@ -706,22 +707,22 @@ static ssize_t efivarfs_file_write(struct file *file, | |||
706 | efivars = var->efivars; | 707 | efivars = var->efivars; |
707 | 708 | ||
708 | if (copy_from_user(&attributes, userbuf, sizeof(attributes))) { | 709 | if (copy_from_user(&attributes, userbuf, sizeof(attributes))) { |
709 | count = -EFAULT; | 710 | bytes = -EFAULT; |
710 | goto out; | 711 | goto out; |
711 | } | 712 | } |
712 | 713 | ||
713 | if (attributes & ~(EFI_VARIABLE_MASK)) { | 714 | if (attributes & ~(EFI_VARIABLE_MASK)) { |
714 | count = -EINVAL; | 715 | bytes = -EINVAL; |
715 | goto out; | 716 | goto out; |
716 | } | 717 | } |
717 | 718 | ||
718 | if (copy_from_user(data, userbuf + sizeof(attributes), datasize)) { | 719 | if (copy_from_user(data, userbuf + sizeof(attributes), datasize)) { |
719 | count = -EFAULT; | 720 | bytes = -EFAULT; |
720 | goto out; | 721 | goto out; |
721 | } | 722 | } |
722 | 723 | ||
723 | if (validate_var(&var->var, data, datasize) == false) { | 724 | if (validate_var(&var->var, data, datasize) == false) { |
724 | count = -EINVAL; | 725 | bytes = -EINVAL; |
725 | goto out; | 726 | goto out; |
726 | } | 727 | } |
727 | 728 | ||
@@ -744,6 +745,8 @@ static ssize_t efivarfs_file_write(struct file *file, | |||
744 | return efi_status_to_err(status); | 745 | return efi_status_to_err(status); |
745 | } | 746 | } |
746 | 747 | ||
748 | bytes = count; | ||
749 | |||
747 | /* | 750 | /* |
748 | * Writing to the variable may have caused a change in size (which | 751 | * Writing to the variable may have caused a change in size (which |
749 | * could either be an append or an overwrite), or the variable to be | 752 | * could either be an append or an overwrite), or the variable to be |
@@ -778,7 +781,7 @@ static ssize_t efivarfs_file_write(struct file *file, | |||
778 | out: | 781 | out: |
779 | kfree(data); | 782 | kfree(data); |
780 | 783 | ||
781 | return count; | 784 | return bytes; |
782 | } | 785 | } |
783 | 786 | ||
784 | static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, | 787 | static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf, |