diff options
author | H. Peter Anvin <hpa@zytor.com> | 2008-08-26 02:35:25 +0200 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2008-08-26 02:46:12 +0200 |
commit | 9ea2b82ed6265a31f9a84886d74d8a2ef01b27c8 (patch) | |
tree | c42e3515b37c0e16e03e230d8cf28d07b240d9b2 /arch/x86/kernel/cpuid.c | |
parent | x86: msr: correct return value on partial operations (diff) | |
download | linux-9ea2b82ed6265a31f9a84886d74d8a2ef01b27c8.tar.xz linux-9ea2b82ed6265a31f9a84886d74d8a2ef01b27c8.zip |
x86: cpuid: correct return value on partial operations
Return the correct return value when the CPUID driver partially
completes a request (we should return the number of bytes actually
read or written, instead of the error code.)
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'arch/x86/kernel/cpuid.c')
-rw-r--r-- | arch/x86/kernel/cpuid.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index 23e8316c8357..8e9cd6a8ec12 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c @@ -89,7 +89,8 @@ static ssize_t cpuid_read(struct file *file, char __user *buf, struct cpuid_regs cmd; int cpu = iminor(file->f_path.dentry->d_inode); u64 pos = *ppos; - int err; + ssize_t bytes = 0; + int err = 0; if (count % 16) return -EINVAL; /* Invalid chunk size */ @@ -99,14 +100,17 @@ static ssize_t cpuid_read(struct file *file, char __user *buf, cmd.ecx = pos >> 32; err = smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1); if (err) - return err; - if (copy_to_user(tmp, &cmd, 16)) - return -EFAULT; + break; + if (copy_to_user(tmp, &cmd, 16)) { + err = -EFAULT; + break; + } tmp += 16; + bytes += 16; *ppos = ++pos; } - return tmp - buf; + return bytes ? bytes : err; } static int cpuid_open(struct inode *inode, struct file *file) |