aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2018-08-21 21:57:50 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-22 10:52:48 -0700
commit4cab63cea374c684eb0db352b40a09e3f7c45057 (patch)
treea6b088095c1b9388cd2142b9a62691f4d533737b
parentcheckpatch: validate SPDX license with spdxcheck.py (diff)
downloadlinux-dev-4cab63cea374c684eb0db352b40a09e3f7c45057.tar.xz
linux-dev-4cab63cea374c684eb0db352b40a09e3f7c45057.zip
checkpatch: fix krealloc reuse test
The current krealloc test does not function correctly when the temporary pointer return name contains the original pointer name. Fix that by maximally matching the return pointer name and the original pointer name and doing a separate comparison of the both names. Link: http://lkml.kernel.org/r/e617ecb8c019a9c4c56540a1bec16c8aed43a4e4.camel@perches.com Signed-off-by: Joe Perches <joe@perches.com> Reported-by: Lars-Peter Clausen <lars@metafoo.de> Cc: Manish Narani <manish.narani@xilinx.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to '')
-rwxr-xr-xscripts/checkpatch.pl3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4523dd6d0476..d43a446941ce 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6167,7 +6167,8 @@ sub process {
# check for krealloc arg reuse
if ($perl_version_ok &&
- $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {
+ $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*($Lval)\s*,/ &&
+ $1 eq $3) {
WARN("KREALLOC_ARG_REUSE",
"Reusing the krealloc arg is almost always a bug\n" . $herecurr);
}