Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 7 additions & 24 deletions drivers/firmware/efi/capsule-loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,29 +234,6 @@ static ssize_t efi_capsule_write(struct file *file, const char __user *buff,
return ret;
}

/**
* efi_capsule_flush - called by file close or file flush
* @file: file pointer
* @id: not used
*
* If a capsule is being partially uploaded then calling this function
* will be treated as upload termination and will free those completed
* buffer pages and -ECANCELED will be returned.
**/
static int efi_capsule_flush(struct file *file, fl_owner_t id)
{
int ret = 0;
struct capsule_info *cap_info = file->private_data;

if (cap_info->index > 0) {
pr_err("%s: capsule upload not complete\n", __func__);
efi_free_all_buff_pages(cap_info);
ret = -ECANCELED;
}

return ret;
}

/**
* efi_capsule_release - called by file close
* @inode: not used
Expand All @@ -269,6 +246,13 @@ static int efi_capsule_release(struct inode *inode, struct file *file)
{
struct capsule_info *cap_info = file->private_data;

if (cap_info->index > 0 &&
(cap_info->header.headersize == 0 ||
cap_info->count < cap_info->total_size)) {
pr_err("capsule upload not complete\n");
efi_free_all_buff_pages(cap_info);
}

kfree(cap_info->pages);
kfree(file->private_data);
file->private_data = NULL;
Expand Down Expand Up @@ -308,7 +292,6 @@ static const struct file_operations efi_capsule_fops = {
.owner = THIS_MODULE,
.open = efi_capsule_open,
.write = efi_capsule_write,
.flush = efi_capsule_flush,
.release = efi_capsule_release,
.llseek = no_llseek,
};
Expand Down