]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
x86, msr: Remove incorrect, duplicated code in the MSR driver
authorH. Peter Anvin <hpa@zytor.com>
Mon, 14 Dec 2009 18:02:18 +0000 (10:02 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Mon, 14 Dec 2009 18:05:05 +0000 (10:05 -0800)
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>
arch/x86/kernel/msr.c

index 553449951b84b9c2d2f24afc2521fdd53adb7c8f..572b07eee3f421570047343bae9fb42a4a93dc7b 100644 (file)
@@ -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 */