Skip to content

Commit

Permalink
efivarfs: efivarfs_file_read ensure we free data in error paths
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Andy Whitcroft authored and Matt Fleming committed Oct 30, 2012
1 parent bd52276 commit d142df0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/firmware/efivars.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
unsigned long datasize = 0;
u32 attributes;
void *data;
ssize_t size;
ssize_t size = 0;

status = efivars->ops->get_variable(var->var.VariableName,
&var->var.VendorGuid,
Expand All @@ -784,13 +784,13 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
&var->var.VendorGuid,
&attributes, &datasize,
(data + 4));

if (status != EFI_SUCCESS)
return 0;
goto out_free;

memcpy(data, &attributes, 4);
size = simple_read_from_buffer(userbuf, count, ppos,
data, datasize + 4);
out_free:
kfree(data);

return size;
Expand Down

0 comments on commit d142df0

Please sign in to comment.