summaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl17
1 files changed, 17 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 182be0f12407..ac1d6b0a6f09 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4014,6 +4014,23 @@ sub process {
4014 } 4014 }
4015 } 4015 }
4016 4016
4017# check for unnecessary "Out of Memory" messages
4018 if ($line =~ /^\+.*\b$logFunctions\s*\(/ &&
4019 $prevline =~ /^[ \+]\s*if\s*\(\s*(\!\s*|NULL\s*==\s*)?($Lval)(\s*==\s*NULL\s*)?\s*\)/ &&
4020 (defined $1 || defined $3) &&
4021 $linenr > 3) {
4022 my $testval = $2;
4023 my $testline = $lines[$linenr - 3];
4024
4025 my ($s, $c) = ctx_statement_block($linenr - 3, $realcnt, 0);
4026# print("line: <$line>\nprevline: <$prevline>\ns: <$s>\nc: <$c>\n\n\n");
4027
4028 if ($c =~ /(?:^|\n)[ \+]\s*(?:$Type\s*)?\Q$testval\E\s*=\s*(?:\([^\)]*\)\s*)?\s*(?:devm_)?(?:[kv][czm]alloc(?:_node|_array)?\b|kstrdup|(?:dev_)?alloc_skb)/) {
4029 WARN("OOM_MESSAGE",
4030 "Possible unnecessary 'out of memory' message\n" . $hereprev);
4031 }
4032 }
4033
4017# check for bad placement of section $InitAttribute (e.g.: __initdata) 4034# check for bad placement of section $InitAttribute (e.g.: __initdata)
4018 if ($line =~ /(\b$InitAttribute\b)/) { 4035 if ($line =~ /(\b$InitAttribute\b)/) {
4019 my $attr = $1; 4036 my $attr = $1;