From patchwork Mon May 16 21:19:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 1503 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:52:33 -0000 Delivered-To: patches@linaro.org Received: by 10.224.61.3 with SMTP id r3cs96501qah; Mon, 16 May 2011 14:19:25 -0700 (PDT) Received: by 10.91.50.25 with SMTP id c25mr3697970agk.163.1305580765025; Mon, 16 May 2011 14:19:25 -0700 (PDT) Received: from e9.ny.us.ibm.com (e9.ny.us.ibm.com [32.97.182.139]) by mx.google.com with ESMTPS id g18si10895987anh.107.2011.05.16.14.19.23 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 May 2011 14:19:24 -0700 (PDT) Received-SPF: pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.139 as permitted sender) client-ip=32.97.182.139; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jstultz@us.ibm.com designates 32.97.182.139 as permitted sender) smtp.mail=jstultz@us.ibm.com Received: from d01relay07.pok.ibm.com (d01relay07.pok.ibm.com [9.56.227.147]) by e9.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p4GKo03M023774; Mon, 16 May 2011 16:50:00 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay07.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p4GLJMQ4897174; Mon, 16 May 2011 17:19:22 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p4GHJ8vO030188; Mon, 16 May 2011 14:19:09 -0300 Received: from kernel.beaverton.ibm.com (kernel.beaverton.ibm.com [9.47.67.96]) by d01av03.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p4GHJ8CS030152; Mon, 16 May 2011 14:19:08 -0300 Received: by kernel.beaverton.ibm.com (Postfix, from userid 1056) id 371781E7511; Mon, 16 May 2011 14:19:19 -0700 (PDT) From: John Stultz To: LKML Cc: John Stultz , "Ted Ts'o" , Michal Nazarewicz , Jiri Slaby , KOSAKI Motohiro , David Rientjes , Dave Hansen , Andrew Morton , linux-mm@kvack.org Subject: [PATCH 3/3] checkpatch.pl: Add check for task comm references Date: Mon, 16 May 2011 14:19:17 -0700 Message-Id: <1305580757-13175-4-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.7.3.2.146.gca209 In-Reply-To: <1305580757-13175-1-git-send-email-john.stultz@linaro.org> References: <1305580757-13175-1-git-send-email-john.stultz@linaro.org> Now that accessing current->comm needs to be protected, avoid new current->comm or other task->comm usage by adding a warning to checkpatch.pl. Fair warning: I know zero perl, so this was written in the style of "monkey see, monkey do". It does appear to work in my testing though. Thanks to Jiri Slaby and Michal Nazarewicz for help improving the regex! Close review and feedback would be appreciated. CC: Ted Ts'o CC: Michal Nazarewicz CC: Jiri Slaby CC: KOSAKI Motohiro CC: David Rientjes CC: Dave Hansen CC: Andrew Morton CC: linux-mm@kvack.org Signed-off-by: John Stultz --- scripts/checkpatch.pl | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index d867081..3a713c2 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2868,6 +2868,10 @@ sub process { WARN("usage of NR_CPUS is often wrong - consider using cpu_possible(), num_possible_cpus(), for_each_possible_cpu(), etc\n" . $herecurr); } +# check for current->comm usage + if ($line =~ /\b(?:current|task|tsk|t)\s*->\s*comm\b/) { + WARN("comm access needs to be protected. Use get_task_comm, or printk's \%ptc formatting.\n" . $herecurr); + } # check for %L{u,d,i} in strings my $string; while ($line =~ /(?:^|")([X\t]*)(?:"|$)/g) {