Skip to content

Commit

Permalink
x86, msr: Remove incorrect, duplicated code in the MSR driver
Browse files Browse the repository at this point in the history
The MSR driver would compute the values for cpu and c at declaration,
and then again in the body of the function.  This isn't merely
redundant, but unsafe, since cpu might not refer to a valid CPU at
that point.

Remove the unnecessary and dangerous references in the declarations.
This code now matches the equivalent code in the CPUID driver.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
  • Loading branch information
H. Peter Anvin committed Dec 14, 2009
1 parent 70fe440 commit 494c2eb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions arch/x86/kernel/msr.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,10 @@ static long msr_ioctl(struct file *file, unsigned int ioc, unsigned long arg)

static int msr_open(struct inode *inode, struct file *file)
{
unsigned int cpu = iminor(file->f_path.dentry->d_inode);
struct cpuinfo_x86 *c = &cpu_data(cpu);
unsigned int cpu;
struct cpuinfo_x86 *c;

cpu = iminor(file->f_path.dentry->d_inode);

if (cpu >= nr_cpu_ids || !cpu_online(cpu))
return -ENXIO; /* No such CPU */

Expand Down

0 comments on commit 494c2eb

Please sign in to comment.