diff options
Diffstat (limited to 'arch/x86/kernel/cpuid.c')
| -rw-r--r-- | arch/x86/kernel/cpuid.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c index 3fa4e926b510..6a44d6465991 100644 --- a/arch/x86/kernel/cpuid.c +++ b/arch/x86/kernel/cpuid.c | |||
| @@ -88,6 +88,8 @@ static ssize_t cpuid_read(struct file *file, char __user *buf, | |||
| 88 | struct cpuid_regs cmd; | 88 | struct cpuid_regs cmd; |
| 89 | int cpu = iminor(file->f_path.dentry->d_inode); | 89 | int cpu = iminor(file->f_path.dentry->d_inode); |
| 90 | u64 pos = *ppos; | 90 | u64 pos = *ppos; |
| 91 | ssize_t bytes = 0; | ||
| 92 | int err = 0; | ||
| 91 | 93 | ||
| 92 | if (count % 16) | 94 | if (count % 16) |
| 93 | return -EINVAL; /* Invalid chunk size */ | 95 | return -EINVAL; /* Invalid chunk size */ |
| @@ -95,14 +97,19 @@ static ssize_t cpuid_read(struct file *file, char __user *buf, | |||
| 95 | for (; count; count -= 16) { | 97 | for (; count; count -= 16) { |
| 96 | cmd.eax = pos; | 98 | cmd.eax = pos; |
| 97 | cmd.ecx = pos >> 32; | 99 | cmd.ecx = pos >> 32; |
| 98 | smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1); | 100 | err = smp_call_function_single(cpu, cpuid_smp_cpuid, &cmd, 1); |
| 99 | if (copy_to_user(tmp, &cmd, 16)) | 101 | if (err) |
| 100 | return -EFAULT; | 102 | break; |
| 103 | if (copy_to_user(tmp, &cmd, 16)) { | ||
| 104 | err = -EFAULT; | ||
| 105 | break; | ||
| 106 | } | ||
| 101 | tmp += 16; | 107 | tmp += 16; |
| 108 | bytes += 16; | ||
| 102 | *ppos = ++pos; | 109 | *ppos = ++pos; |
| 103 | } | 110 | } |
| 104 | 111 | ||
| 105 | return tmp - buf; | 112 | return bytes ? bytes : err; |
| 106 | } | 113 | } |
| 107 | 114 | ||
| 108 | static int cpuid_open(struct inode *inode, struct file *file) | 115 | static int cpuid_open(struct inode *inode, struct file *file) |
