[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKwvOdkjoavonG0siOmUq4X-Qngvkn3JHcQ3Hee_h2wJ1AZjeg@mail.gmail.com>
Date: Thu, 7 Mar 2019 16:53:34 -0800
From: Nick Desaulniers <ndesaulniers@...gle.com>
To: Nathan Chancellor <natechancellor@...il.com>
Cc: Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
LKML <linux-kernel@...r.kernel.org>,
clang-built-linux@...glegroups.com
Subject: Re: [PATCH] x86/hw_breakpoints: Return -EINVAL in default case in hw_breakpoint_arch_parse
On Thu, Mar 7, 2019 at 1:28 PM Nathan Chancellor
<natechancellor@...il.com> wrote:
>
> When building with -Wsometimes-uninitialized, Clang warns:
>
> arch/x86/kernel/hw_breakpoint.c:355:2: warning: variable 'align' is used
> uninitialized whenever switch default is taken
> [-Wsometimes-uninitialized]
>
> It's not wrong but we can see that arch_build_bp_info will only ever
> initialize hw->len to one of the specified switch cases. We can easily
> silence Clang by just returning -EINVAL in the default case so that we
> can never use align without initializing it first.
And the call site just bubbles up return codes anyways. Thanks for sending.
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
>
> Link: https://github.com/ClangBuiltLinux/linux/issues/392
> Suggested-by: Nick Desaulniers <ndesaulniers@...gle.com>
> Signed-off-by: Nathan Chancellor <natechancellor@...il.com>
> ---
> arch/x86/kernel/hw_breakpoint.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c
> index ff9bfd40429e..d73083021002 100644
> --- a/arch/x86/kernel/hw_breakpoint.c
> +++ b/arch/x86/kernel/hw_breakpoint.c
> @@ -354,6 +354,7 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,
> #endif
> default:
> WARN_ON_ONCE(1);
> + return -EINVAL;
> }
>
> /*
> --
> 2.21.0
>
--
Thanks,
~Nick Desaulniers
Powered by blists - more mailing lists