aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2018-04-10 19:33:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-11 13:28:36 -0400
commit478b17998066a6a70a7f265f4feba09c6945ab62 (patch)
tree78ad1e87b9d73a99cfd409a673123d48ddb182d4 /scripts
parente3c6bc95668b9b9fc1e74f221551dfa622ea9061 (diff)
checkpatch: improve get_quoted_string for TRACE_EVENT macros
The get_quoted_string function does not expect invalid arguments. The $stat test can return non-statements for complicated macros like TRACE_EVENT. Allow the $stat block and test for vsprintf misuses to exceed the actual block length and possibly test invalid lines by validating the arguments of get_quoted_string. Return "" if either get_quoted_string argument is undefined. Miscellanea: o Properly align the comment for the vsprintf extension test Link: http://lkml.kernel.org/r/9e9725342ca3dfc0f5e3e0b8ca3c482b0e5712cc.1520356392.git.joe@perches.com Signed-off-by: Joe Perches <joe@perches.com> Reported-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 788c90c1ae2a..18bf4bf1d0fc 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1298,6 +1298,7 @@ sub sanitise_line {
1298sub get_quoted_string { 1298sub get_quoted_string {
1299 my ($line, $rawline) = @_; 1299 my ($line, $rawline) = @_;
1300 1300
1301 return "" if (!defined($line) || !defined($rawline));
1301 return "" if ($line !~ m/($String)/g); 1302 return "" if ($line !~ m/($String)/g);
1302 return substr($rawline, $-[0], $+[0] - $-[0]); 1303 return substr($rawline, $-[0], $+[0] - $-[0]);
1303} 1304}
@@ -5807,7 +5808,7 @@ sub process {
5807 } 5808 }
5808 } 5809 }
5809 5810
5810 # check for vsprintf extension %p<foo> misuses 5811# check for vsprintf extension %p<foo> misuses
5811 if ($^V && $^V ge 5.10.0 && 5812 if ($^V && $^V ge 5.10.0 &&
5812 defined $stat && 5813 defined $stat &&
5813 $stat =~ /^\+(?![^\{]*\{\s*).*\b(\w+)\s*\(.*$String\s*,/s && 5814 $stat =~ /^\+(?![^\{]*\{\s*).*\b(\w+)\s*\(.*$String\s*,/s &&