]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
checkpatch: Warn about context_unsafe() without comment
authorMarco Elver <elver@google.com>
Fri, 19 Dec 2025 15:39:54 +0000 (16:39 +0100)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 5 Jan 2026 15:43:27 +0000 (16:43 +0100)
Warn about applications of context_unsafe() without a comment, to
encourage documenting the reasoning behind why it was deemed safe.

Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20251219154418.3592607-6-elver@google.com
scripts/checkpatch.pl

index c0250244cf7a3cb5e289b04fa4a9f644692dc278..c4fd8bdff528ba1f01cb917c54ef8cd83775c8af 100755 (executable)
@@ -6733,6 +6733,13 @@ sub process {
                        }
                }
 
+# check for context_unsafe without a comment.
+               if ($line =~ /\bcontext_unsafe\b/ &&
+                   !ctx_has_comment($first_line, $linenr)) {
+                       WARN("CONTEXT_UNSAFE",
+                            "context_unsafe without comment\n" . $herecurr);
+               }
+
 # check of hardware specific defines
                if ($line =~ m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ m@include/asm-@) {
                        CHK("ARCH_DEFINES",