Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754242AbZA0Fji (ORCPT ); Tue, 27 Jan 2009 00:39:38 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751612AbZA0Fj3 (ORCPT ); Tue, 27 Jan 2009 00:39:29 -0500 Received: from bombadil.infradead.org ([18.85.46.34]:50605 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751573AbZA0Fj3 (ORCPT ); Tue, 27 Jan 2009 00:39:29 -0500 Date: Tue, 27 Jan 2009 00:39:20 -0500 From: Kyle McMartin To: Andrew Morton Cc: Kyle McMartin , KOSAKI Motohiro , Christoph Bartelmus , linux-kernel@vger.kernel.org, Linus Torvalds , Andy Whitcroft Subject: [PATCH] make checkpatch warn about access to current->comm Message-ID: <20090127053920.GB5034@bombadil.infradead.org> References: <20090120071641.B0A3.KOSAKI.MOTOHIRO@jp.fujitsu.com> <20090128140615.D464.KOSAKI.MOTOHIRO@jp.fujitsu.com> <20090126211655.c7287768.akpm@linux-foundation.org> <20090127051919.GA5034@bombadil.infradead.org> <20090126212615.2658b29e.akpm@linux-foundation.org> <20090126212918.d4770115.akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090126212918.d4770115.akpm@linux-foundation.org> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1064 Lines: 33 From: Kyle McMartin Suggest using the get_task_comm accessor versus direct access to current->comm. Signed-off-by: Kyle McMartin --- I just mashed it in the middle of existing checks to minimize risk of collisions. diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 45eb0ae..4f2da5d 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2533,6 +2533,11 @@ sub process { $herecurr); } +# direct access to current task name is racy, suggest accessor instead. + if ($line =~ /current\-\>comm/) { + WARN("direct access to current->comm is racy, use get_task_comm() instead.\n" . $herecurr); + } + # use of NR_CPUS is usually wrong # ignore definitions of NR_CPUS and usage to define arrays as likely right if ($line =~ /\bNR_CPUS\b/ && -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/