From 478b17998066a6a70a7f265f4feba09c6945ab62 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Tue, 10 Apr 2018 16:33:34 -0700 Subject: 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 Reported-by: Chuck Lever Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') 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 { sub get_quoted_string { my ($line, $rawline) = @_; + return "" if (!defined($line) || !defined($rawline)); return "" if ($line !~ m/($String)/g); return substr($rawline, $-[0], $+[0] - $-[0]); } @@ -5807,7 +5808,7 @@ sub process { } } - # check for vsprintf extension %p misuses +# check for vsprintf extension %p misuses if ($^V && $^V ge 5.10.0 && defined $stat && $stat =~ /^\+(?![^\{]*\{\s*).*\b(\w+)\s*\(.*$String\s*,/s && -- cgit v1.2.3