diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a2e4a3d9c6d7cbfdc4b24fbd92224b45a9a85ec0..2e513fdf3043eeed2fc37372c2d8c2cc0db06a32 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1417,7 +1417,8 @@ sub process {
 			$s =~ s/\n./\n/gs;
 
 			# Find out how long the conditional actually is.
-			my $cond_lines = 0 + $c =~ /\n/gs;
+			my @newlines = ($c =~ /\n/gs);
+			my $cond_lines = 1 + $#newlines;
 
 			# We want to check the first line inside the block
 			# starting at the end of the conditional, so remove: