diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 788c90c1ae2a732ef670135784e9c3af96562de6..18bf4bf1d0fc6242739dd3bc173d939145976247 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<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 &&