aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@canonical.com>2012-10-11 06:32:17 -0400
committerMatt Fleming <matt.fleming@intel.com>2012-10-30 06:39:21 -0400
commitd142df03a798ee7d2db10a1f20945110ea6067ff (patch)
tree2bdfa599c3de25faf1ed7507b48c20bae66ce20f /drivers/firmware
parentbd52276fa1d420c3a504b76ffaaa1642cc79d4c4 (diff)
efivarfs: efivarfs_file_read ensure we free data in error paths
Signed-off-by: Andy Whitcroft <apw@canonical.com> Acked-by: Matthew Garrett <mjg@redhat.com> Acked-by: Jeremy Kerr <jeremy.kerr@canonical.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/efivars.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/firmware/efivars.c b/drivers/firmware/efivars.c
index 6793965b7c8b..b7c9a3261dc4 100644
--- a/drivers/firmware/efivars.c
+++ b/drivers/firmware/efivars.c
@@ -766,7 +766,7 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
766 unsigned long datasize = 0; 766 unsigned long datasize = 0;
767 u32 attributes; 767 u32 attributes;
768 void *data; 768 void *data;
769 ssize_t size; 769 ssize_t size = 0;
770 770
771 status = efivars->ops->get_variable(var->var.VariableName, 771 status = efivars->ops->get_variable(var->var.VariableName,
772 &var->var.VendorGuid, 772 &var->var.VendorGuid,
@@ -784,13 +784,13 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
784 &var->var.VendorGuid, 784 &var->var.VendorGuid,
785 &attributes, &datasize, 785 &attributes, &datasize,
786 (data + 4)); 786 (data + 4));
787
788 if (status != EFI_SUCCESS) 787 if (status != EFI_SUCCESS)
789 return 0; 788 goto out_free;
790 789
791 memcpy(data, &attributes, 4); 790 memcpy(data, &attributes, 4);
792 size = simple_read_from_buffer(userbuf, count, ppos, 791 size = simple_read_from_buffer(userbuf, count, ppos,
793 data, datasize + 4); 792 data, datasize + 4);
793out_free:
794 kfree(data); 794 kfree(data);
795 795
796 return size; 796 return size;