From: Joe Perches Date: Wed, 22 Aug 2018 04:57:50 +0000 (-0700) Subject: checkpatch: fix krealloc reuse test X-Git-Tag: v4.19~329^2~67 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4cab63cea374c684eb0db352b40a09e3f7c45057;p=platform%2Fkernel%2Flinux-rpi.git 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 Reported-by: Lars-Peter Clausen Cc: Manish Narani Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4523dd6..d43a446 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); }