|
@@ -4014,6 +4014,23 @@ sub process {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+# check for unnecessary "Out of Memory" messages
|
|
|
+ if ($line =~ /^\+.*\b$logFunctions\s*\(/ &&
|
|
|
+ $prevline =~ /^[ \+]\s*if\s*\(\s*(\!\s*|NULL\s*==\s*)?($Lval)(\s*==\s*NULL\s*)?\s*\)/ &&
|
|
|
+ (defined $1 || defined $3) &&
|
|
|
+ $linenr > 3) {
|
|
|
+ my $testval = $2;
|
|
|
+ my $testline = $lines[$linenr - 3];
|
|
|
+
|
|
|
+ my ($s, $c) = ctx_statement_block($linenr - 3, $realcnt, 0);
|
|
|
+# print("line: <$line>\nprevline: <$prevline>\ns: <$s>\nc: <$c>\n\n\n");
|
|
|
+
|
|
|
+ if ($c =~ /(?:^|\n)[ \+]\s*(?:$Type\s*)?\Q$testval\E\s*=\s*(?:\([^\)]*\)\s*)?\s*(?:devm_)?(?:[kv][czm]alloc(?:_node|_array)?\b|kstrdup|(?:dev_)?alloc_skb)/) {
|
|
|
+ WARN("OOM_MESSAGE",
|
|
|
+ "Possible unnecessary 'out of memory' message\n" . $hereprev);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
# check for bad placement of section $InitAttribute (e.g.: __initdata)
|
|
|
if ($line =~ /(\b$InitAttribute\b)/) {
|
|
|
my $attr = $1;
|