Skip to content

Commit 556e75a

Browse files
AndrewScullgregkh
authored andcommitted
bug: Remove redundant condition check in report_bug
[ Upstream commit 3ad1a6c ] report_bug() will return early if it cannot find a bug corresponding to the provided address. The subsequent test for the bug will always be true so remove it. Fixes: 1b4cfe3 ("lib/bug.c: exclude non-BUG/WARN exceptions from report_bug()") Signed-off-by: Andrew Scull <ascull@google.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: "Steven Rostedt (VMware)" <rostedt@goodmis.org> Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Acked-by: Will Deacon <will@kernel.org> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20210318143311.839894-2-ascull@google.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent faba97a commit 556e75a

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

‎lib/bug.c‎

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,30 +158,27 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
158158

159159
file = NULL;
160160
line = 0;
161-
warning = 0;
162161

163-
if (bug) {
164162
#ifdef CONFIG_DEBUG_BUGVERBOSE
165163
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
166-
file = bug->file;
164+
file = bug->file;
167165
#else
168-
file = (const char *)bug + bug->file_disp;
166+
file = (const char *)bug + bug->file_disp;
169167
#endif
170-
line = bug->line;
168+
line = bug->line;
171169
#endif
172-
warning = (bug->flags & BUGFLAG_WARNING) != 0;
173-
once = (bug->flags & BUGFLAG_ONCE) != 0;
174-
done = (bug->flags & BUGFLAG_DONE) != 0;
175-
176-
if (warning && once) {
177-
if (done)
178-
return BUG_TRAP_TYPE_WARN;
179-
180-
/*
181-
* Since this is the only store, concurrency is not an issue.
182-
*/
183-
bug->flags |= BUGFLAG_DONE;
184-
}
170+
warning = (bug->flags & BUGFLAG_WARNING) != 0;
171+
once = (bug->flags & BUGFLAG_ONCE) != 0;
172+
done = (bug->flags & BUGFLAG_DONE) != 0;
173+
174+
if (warning && once) {
175+
if (done)
176+
return BUG_TRAP_TYPE_WARN;
177+
178+
/*
179+
* Since this is the only store, concurrency is not an issue.
180+
*/
181+
bug->flags |= BUGFLAG_DONE;
185182
}
186183

187184
/*

0 commit comments

Comments
 (0)