]>
Commit | Line | Data |
---|---|---|
38edc49d SLM |
1 | From fe08eaf763ced50fe133747dc36364dfa085620a Mon Sep 17 00:00:00 2001 |
2 | From: Nathan Chancellor <natechancellor@gmail.com> | |
3 | Date: Thu, 7 Mar 2019 14:27:56 -0700 | |
4 | Subject: x86/hw_breakpoints: Make default case in hw_breakpoint_arch_parse() | |
5 | return an error | |
6 | ||
7 | [ Upstream commit e898e69d6b9475bf123f99b3c5d1a67bb7cb2361 ] | |
8 | ||
9 | When building with -Wsometimes-uninitialized, Clang warns: | |
10 | ||
11 | arch/x86/kernel/hw_breakpoint.c:355:2: warning: variable 'align' is used | |
12 | uninitialized whenever switch default is taken | |
13 | [-Wsometimes-uninitialized] | |
14 | ||
15 | The default cannot be reached because arch_build_bp_info() initializes | |
16 | hw->len to one of the specified cases. Nevertheless the warning is valid | |
17 | and returning -EINVAL makes sure that this cannot be broken by future | |
18 | modifications. | |
19 | ||
20 | Suggested-by: Nick Desaulniers <ndesaulniers@google.com> | |
21 | Signed-off-by: Nathan Chancellor <natechancellor@gmail.com> | |
22 | Signed-off-by: Thomas Gleixner <tglx@linutronix.de> | |
23 | Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> | |
24 | Cc: Borislav Petkov <bp@alien8.de> | |
25 | Cc: "H. Peter Anvin" <hpa@zytor.com> | |
26 | Cc: clang-built-linux@googlegroups.com | |
27 | Link: https://github.com/ClangBuiltLinux/linux/issues/392 | |
28 | Link: https://lkml.kernel.org/r/20190307212756.4648-1-natechancellor@gmail.com | |
29 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
30 | --- | |
31 | arch/x86/kernel/hw_breakpoint.c | 1 + | |
32 | 1 file changed, 1 insertion(+) | |
33 | ||
34 | diff --git a/arch/x86/kernel/hw_breakpoint.c b/arch/x86/kernel/hw_breakpoint.c | |
35 | index 2bcfb5f2bc44..433f17d154e2 100644 | |
36 | --- a/arch/x86/kernel/hw_breakpoint.c | |
37 | +++ b/arch/x86/kernel/hw_breakpoint.c | |
38 | @@ -351,6 +351,7 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp) | |
39 | #endif | |
40 | default: | |
41 | WARN_ON_ONCE(1); | |
42 | + return -EINVAL; | |
43 | } | |
44 | ||
45 | /* | |
46 | -- | |
47 | 2.19.1 | |
48 |