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 lenght 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 Signed-off-by: Joe Perches <j...@perches.com> Reported-by: Chuck Lever <chuck.le...@oracle.com> --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 16e542f4e027..5a6cef8f2376 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]); } @@ -5817,7 +5818,7 @@ sub process { } } - # check for vsprintf extension %p<foo> misuses +# check for vsprintf extension %p<foo> misuses if ($^V && $^V ge 5.10.0 && defined $stat && $stat =~ /^\+(?![^\{]*\{\s*).*\b(\w+)\s*\(.*$String\s*,/s && -- 2.15.0