Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 1b4cfe3c0a30d ("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

authored by

Andrew Scull and committed by
Marc Zyngier
3ad1a6cb 1e28eed1

+13 -16
+13 -16
lib/bug.c
··· 155 155 156 156 file = NULL; 157 157 line = 0; 158 - warning = 0; 159 158 160 - if (bug) { 161 159 #ifdef CONFIG_DEBUG_BUGVERBOSE 162 160 #ifndef CONFIG_GENERIC_BUG_RELATIVE_POINTERS 163 - file = bug->file; 161 + file = bug->file; 164 162 #else 165 - file = (const char *)bug + bug->file_disp; 163 + file = (const char *)bug + bug->file_disp; 166 164 #endif 167 - line = bug->line; 165 + line = bug->line; 168 166 #endif 169 - warning = (bug->flags & BUGFLAG_WARNING) != 0; 170 - once = (bug->flags & BUGFLAG_ONCE) != 0; 171 - done = (bug->flags & BUGFLAG_DONE) != 0; 167 + warning = (bug->flags & BUGFLAG_WARNING) != 0; 168 + once = (bug->flags & BUGFLAG_ONCE) != 0; 169 + done = (bug->flags & BUGFLAG_DONE) != 0; 172 170 173 - if (warning && once) { 174 - if (done) 175 - return BUG_TRAP_TYPE_WARN; 171 + if (warning && once) { 172 + if (done) 173 + return BUG_TRAP_TYPE_WARN; 176 174 177 - /* 178 - * Since this is the only store, concurrency is not an issue. 179 - */ 180 - bug->flags |= BUGFLAG_DONE; 181 - } 175 + /* 176 + * Since this is the only store, concurrency is not an issue. 177 + */ 178 + bug->flags |= BUGFLAG_DONE; 182 179 } 183 180 184 181 /*