[RFC PATCH] checkpatch: check Fixes for a Cc: stable tag

From: Sabrina Dubroca

Date: Mon Sep 28 2026 - 04:06:07 EST


I keep forgetting to add a "Cc: stable@xxxxxxxxxx" tag to my
Fixes. Not all fixes deserve one, but it's a good reminder.

Only print a CHECK-level message if one of the Fixes tags belongs to a
commit present in a released kernel. Fixes for stuff that's only in
-next should be fine without the Cc.

Assisted-by: LLM
Signed-off-by: Sabrina Dubroca <sd@xxxxxxxxxxxxxxx>
---
I don't deserve the credit for more than "suggested-by" on this,
I just fed the idea to claude and it produced this. It seems to do
what I wanted, and looks fairly reasonable to me (as someone who
doesn't know Perl).

scripts/checkpatch.pl | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8a7787d228a6..8f675445ba51 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1292,6 +1292,16 @@ sub git_commit_info {
return ($id, $desc);
}

+sub git_commit_in_release {
+ my ($commit) = @_;
+
+ return undef if ((which("git") eq "") || !(-e "$gitroot"));
+
+ `${git_command} describe --contains --match 'v*' --exclude '*-rc*' $commit 2>/dev/null`;
+
+ return $? == 0;
+}
+
$chk_signoff = 0 if ($file);
$chk_fixes_tag = 0 if ($file);

@@ -2687,6 +2697,8 @@ sub process {
my $fixes_tag = 0;
my $is_revert = 0;
my $needs_fixes_tag = "";
+ my $has_cc_stable = 0;
+ my @old_fixes_without_cc_stable = ();
my $author = '';
my $authorsignoff = 0;
my $author_sob = '';
@@ -3085,6 +3097,11 @@ sub process {
my $email = $4;
my $ucfirst_sign_off = ucfirst(lc($sign_off));

+ if ($sign_off =~ /^cc:$/i &&
+ $email =~ /stable\@(?:vger\.)?kernel\.org/i) {
+ $has_cc_stable = 1;
+ }
+
if ($sign_off !~ /$signature_tags/) {
my $suggested_signature = find_standard_signature($sign_off);
if ($suggested_signature eq "") {
@@ -3309,6 +3326,15 @@ sub process {
$fixed[$fixlinenr] = $fixed;
}
}
+
+ # Cc: stable@xxxxxxxxxxxxxxx may appear later in the
+ # tags block, so defer the check until the whole
+ # commit log has been scanned.
+ if (defined($cid)) {
+ if (git_commit_in_release($cid)) {
+ push(@old_fixes_without_cc_stable, $herecurr);
+ }
+ }
}

# Check email subject for common tools that don't need to be mentioned
@@ -7869,6 +7895,12 @@ sub process {
WARN("MISSING_FIXES_TAG",
"The commit message has '$needs_fixes_tag', perhaps it also needs a 'Fixes:' tag?\n");
}
+ if (!$has_cc_stable) {
+ foreach my $fixes_herecurr (@old_fixes_without_cc_stable) {
+ CHK("MISSING_FIXES_STABLE_TAG",
+ "The commit fixed by the Fixes: tag is already present in a released kernel, should the commit have a Cc: stable tag?\n" . $fixes_herecurr);
+ }
+ }
}
if ($is_patch && $has_commit_log && $chk_signoff) {
if ($signoff == 0) {
--
2.55.0