oprofile, x86: Fix overflow and warning (commit 1d12d35)
authorRobert Richter <robert.richter@amd.com>
Tue, 16 Aug 2011 21:39:53 +0000 (23:39 +0200)
committerRobert Richter <robert.richter@amd.com>
Tue, 16 Aug 2011 21:51:00 +0000 (23:51 +0200)
Following fixes for:

 1d12d35 oprofile, x86: Convert memory allocation to static array

Fix potential buffer overflow.

Fix the following warning:

 arch/x86/oprofile/op_model_ppro.c: In function ‘ppro_check_ctrs’:
 arch/x86/oprofile/op_model_ppro.c:143: warning: label ‘out’ defined but not used

Cc: Maarten Lankhorst <m.b.lankhorst@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Robert Richter <robert.richter@amd.com>
arch/x86/oprofile/op_model_ppro.c

index 608874b70cf46ebdc73f2e6be25409b8114a86f0..d90528ea541206b57f3048e191d4340ee070b40b 100644 (file)
@@ -140,7 +140,6 @@ static int ppro_check_ctrs(struct pt_regs * const regs,
                wrmsrl(msrs->counters[i].addr, -reset_value[i]);
        }
 
-out:
        /* Only P6 based Pentium M need to re-unmask the apic vector but it
         * doesn't hurt other P6 variant */
        apic_write(APIC_LVTPC, apic_read(APIC_LVTPC) & ~APIC_LVT_MASKED);
@@ -220,7 +219,7 @@ static void arch_perfmon_setup_counters(void)
                eax.split.bit_width = 40;
        }
 
-       num_counters = eax.split.num_counters;
+       num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
 
        op_arch_perfmon_spec.num_counters = num_counters;
        op_arch_perfmon_spec.num_controls = num_counters;