Skip to content

Commit 3ad1a6c

Browse files
AndrewScullMarc Zyngier
authored andcommitted
bug: Remove redundant condition check in report_bug
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
1 parent 1e28eed commit 3ad1a6c

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
@@ -155,30 +155,27 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
155155

156156
file = NULL;
157157
line = 0;
158-
warning = 0;
159158

160-
if (bug) {
161159
#ifdef CONFIG_DEBUG_BUGVERBOSE
162160
#ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
163-
file = bug->file;
161+
file = bug->file;
164162
#else
165-
file = (const char *)bug + bug->file_disp;
163+
file = (const char *)bug + bug->file_disp;
166164
#endif
167-
line = bug->line;
165+
line = bug->line;
168166
#endif
169-
warning = (bug->flags & BUGFLAG_WARNING) != 0;
170-
once = (bug->flags & BUGFLAG_ONCE) != 0;
171-
done = (bug->flags & BUGFLAG_DONE) != 0;
172-
173-
if (warning && once) {
174-
if (done)
175-
return BUG_TRAP_TYPE_WARN;
176-
177-
/*
178-
* Since this is the only store, concurrency is not an issue.
179-
*/
180-
bug->flags |= BUGFLAG_DONE;
181-
}
167+
warning = (bug->flags & BUGFLAG_WARNING) != 0;
168+
once = (bug->flags & BUGFLAG_ONCE) != 0;
169+
done = (bug->flags & BUGFLAG_DONE) != 0;
170+
171+
if (warning && once) {
172+
if (done)
173+
return BUG_TRAP_TYPE_WARN;
174+
175+
/*
176+
* Since this is the only store, concurrency is not an issue.
177+
*/
178+
bug->flags |= BUGFLAG_DONE;
182179
}
183180

184181
/*

0 commit comments

Comments
 (0)