summaryrefslogtreecommitdiffstats
path: root/drivers/firmware
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-10-26 12:18:53 +0100
committerMatt Fleming <matt.fleming@intel.com>2012-10-30 10:39:28 +0000
commitcfcf2f11708f934d2bd294f973c2fcb0cc54f293 (patch)
treef92e907f7e56bcf7617c9b56b9bd88450b61729a /drivers/firmware
parentaeeaa8d46aa38c9cc5fac23feb9b1f91bdbf5dd3 (diff)
downloadlinux-cfcf2f11708f934d2bd294f973c2fcb0cc54f293.tar.bz2
efivarfs: Fix return value of efivarfs_file_write()
We're stuffing a variable of type size_t (unsigned) into a ssize_t (signed) which, even though both types should be the same number of bits, it's just asking for sign issues to be introduced. Cc: Jeremy Kerr <jeremy.kerr@canonical.com> Reported-by: Alan Cox <alan@lxorguk.ukuu.org.uk> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'drivers/firmware')
-rw-r--r--drivers/firmware/efivars.c13
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,
struct inode *inode = file->f_mapping->host;
unsigned long datasize = count - sizeof(attributes);
unsigned long newdatasize;
+ ssize_t bytes = 0;
if (count < sizeof(attributes))
return -EINVAL;
@@ -706,22 +707,22 @@ static ssize_t efivarfs_file_write(struct file *file,
efivars = var->efivars;
if (copy_from_user(&attributes, userbuf, sizeof(attributes))) {
- count = -EFAULT;
+ bytes = -EFAULT;
goto out;
}
if (attributes & ~(EFI_VARIABLE_MASK)) {
- count = -EINVAL;
+ bytes = -EINVAL;
goto out;
}
if (copy_from_user(data, userbuf + sizeof(attributes), datasize)) {
- count = -EFAULT;
+ bytes = -EFAULT;
goto out;
}
if (validate_var(&var->var, data, datasize) == false) {
- count = -EINVAL;
+ bytes = -EINVAL;
goto out;
}
@@ -744,6 +745,8 @@ static ssize_t efivarfs_file_write(struct file *file,
return efi_status_to_err(status);
}
+ bytes = count;
+
/*
* Writing to the variable may have caused a change in size (which
* 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,
out:
kfree(data);
- return count;
+ return bytes;
}
static ssize_t efivarfs_file_read(struct file *file, char __user *userbuf,