diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-10-25 02:41:09 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-10-25 02:46:20 -0400 |
commit | 2c78ffeca98fcd5a1dfd4a322438944506ed5e64 (patch) | |
tree | 37a7a9a024a8342828307ca1bcd1c447fbee270a /arch/x86/oprofile | |
parent | aa7b250c252cc8e6b1daf0e1eada5eba42a1a68d (diff) |
x86/oprofile: Fix uninitialized variable use in debug printk
Stephen Rothwell reported this build warning:
arch/x86/oprofile/op_model_amd.c: In function 'ibs_eilvt_valid':
arch/x86/oprofile/op_model_amd.c:289: warning: 'offset' may be used uninitialized in this function
And correctly observed that indeed the variable is used uninitialized in
this function. The result of this bug can be a debug printk with a bogus
value.
Also fix a few more small details that made this function hard to read
and which probably contributed to the bug being introduced to begin with:
- Use more symmetric error conditions
- Remove the !0 obfuscation
- Add newlines to the printk output
- Remove bogus linebreaks in printk strings and elsewhere
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Robert Richter <robert.richter@amd.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
LKML-Reference: <20101025115736.41d51abe.sfr@canb.auug.org.au>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/oprofile')
-rw-r--r-- | arch/x86/oprofile/op_model_amd.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c index 42fb46f83883..68759e716f0f 100644 --- a/arch/x86/oprofile/op_model_amd.c +++ b/arch/x86/oprofile/op_model_amd.c | |||
@@ -281,29 +281,25 @@ static inline int eilvt_is_available(int offset) | |||
281 | 281 | ||
282 | static inline int ibs_eilvt_valid(void) | 282 | static inline int ibs_eilvt_valid(void) |
283 | { | 283 | { |
284 | u64 val; | ||
285 | int offset; | 284 | int offset; |
285 | u64 val; | ||
286 | 286 | ||
287 | rdmsrl(MSR_AMD64_IBSCTL, val); | 287 | rdmsrl(MSR_AMD64_IBSCTL, val); |
288 | offset = val & IBSCTL_LVT_OFFSET_MASK; | ||
289 | |||
288 | if (!(val & IBSCTL_LVT_OFFSET_VALID)) { | 290 | if (!(val & IBSCTL_LVT_OFFSET_VALID)) { |
289 | pr_err(FW_BUG "cpu %d, invalid IBS " | 291 | pr_err(FW_BUG "cpu %d, invalid IBS interrupt offset %d (MSR%08X=0x%016llx)\n", |
290 | "interrupt offset %d (MSR%08X=0x%016llx)", | 292 | smp_processor_id(), offset, MSR_AMD64_IBSCTL, val); |
291 | smp_processor_id(), offset, | ||
292 | MSR_AMD64_IBSCTL, val); | ||
293 | return 0; | 293 | return 0; |
294 | } | 294 | } |
295 | 295 | ||
296 | offset = val & IBSCTL_LVT_OFFSET_MASK; | 296 | if (!eilvt_is_available(offset)) { |
297 | 297 | pr_err(FW_BUG "cpu %d, IBS interrupt offset %d not available (MSR%08X=0x%016llx)\n", | |
298 | if (eilvt_is_available(offset)) | 298 | smp_processor_id(), offset, MSR_AMD64_IBSCTL, val); |
299 | return !0; | 299 | return 0; |
300 | 300 | } | |
301 | pr_err(FW_BUG "cpu %d, IBS interrupt offset %d " | ||
302 | "not available (MSR%08X=0x%016llx)", | ||
303 | smp_processor_id(), offset, | ||
304 | MSR_AMD64_IBSCTL, val); | ||
305 | 301 | ||
306 | return 0; | 302 | return 1; |
307 | } | 303 | } |
308 | 304 | ||
309 | static inline int get_ibs_offset(void) | 305 | static inline int get_ibs_offset(void) |