Re: [tip:perf/urgent] x86/oprofile: Fix uninitialized variable usein debug printk

From: Robert Richter
Date: Mon Oct 25 2010 - 06:23:32 EST


On 25.10.10 02:52:03, tip-bot for Ingo Molnar wrote:
> Commit-ID: 2c78ffeca98fcd5a1dfd4a322438944506ed5e64
> Gitweb: http://git.kernel.org/tip/2c78ffeca98fcd5a1dfd4a322438944506ed5e64
> Author: Ingo Molnar <mingo@xxxxxxx>
> AuthorDate: Mon, 25 Oct 2010 08:41:09 +0200
> Committer: Ingo Molnar <mingo@xxxxxxx>
> CommitDate: Mon, 25 Oct 2010 08:46:20 +0200
>
> 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

Ingo, thanks for changing this, it all looks good to me, though we
actually don't have to print the offset as the valid bit is not set.

For some reason I didn't catch the warning:

...
LD arch/x86/kernel/acpi/built-in.o
CC arch/x86/oprofile/op_model_amd.o
CC arch/x86/kernel/cpu/intel_cacheinfo.o
...

(using gcc (Gentoo 4.4.3-r2 p1.2) 4.4.3)

... but it should warn.

-Robert

>
> Reported-by: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
> Cc: Robert Richter <robert.richter@xxxxxxx>
> Cc: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> LKML-Reference: <20101025115736.41d51abe.sfr@xxxxxxxxxxxxxxxx>
> Signed-off-by: Ingo Molnar <mingo@xxxxxxx>

--
Advanced Micro Devices, Inc.
Operating System Research Center

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/