Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d142df03 authored by Andy Whitcroft's avatar Andy Whitcroft Committed by Matt Fleming
Browse files

efivarfs: efivarfs_file_read ensure we free data in error paths

parent bd52276f
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -766,7 +766,7 @@ static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,
	unsigned long datasize = 0;
	unsigned long datasize = 0;
	u32 attributes;
	u32 attributes;
	void *data;
	void *data;
	ssize_t size;
	ssize_t size = 0;


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

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


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


	return size;
	return size;