From patchwork Mon Nov 17 19:09:51 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 9196 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id BBA16DDECA for ; Tue, 18 Nov 2008 06:11:54 +1100 (EST) X-Original-To: linuxppc-dev@ozlabs.org Delivered-To: linuxppc-dev@ozlabs.org Received: from hrndva-omtalb.mail.rr.com (hrndva-omtalb.mail.rr.com [71.74.56.124]) by ozlabs.org (Postfix) with ESMTP id 2E1934753F for ; Tue, 18 Nov 2008 06:11:16 +1100 (EST) Received: from gandalf.stny.rr.com ([74.67.89.75]) by hrndva-omta03.mail.rr.com with ESMTP id <20081117191101.SDYL2107.hrndva-omta03.mail.rr.com@gandalf.stny.rr.com>; Mon, 17 Nov 2008 19:11:01 +0000 Received: from rostedt by gandalf.stny.rr.com with local (Exim 4.69) (envelope-from ) id 1L29Ux-0003z7-P4; Mon, 17 Nov 2008 14:10:59 -0500 Message-Id: <20081117191059.610706327@goodmis.org> References: <20081117190948.619751203@goodmis.org> User-Agent: quilt/0.46-1 Date: Mon, 17 Nov 2008 14:09:51 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Subject: [PATCH 3/4] ftrace,ppc: fix module check in dynamic ftrace code Content-Disposition: inline; filename=0003-ftrace-ppc-fix-module-check-in-dynamic-ftrace-code.patch Cc: Andrew Morton , Peter Zijlstra , Rusty Russell , Pekka Paalanen , David Miller , linuxppc-dev@ozlabs.org, Steven Rostedt , Paul Mundt , Paul Mackerras , Frederic Weisbecker , Ingo Molnar , Thomas Gleixner X-BeenThere: linuxppc-dev@ozlabs.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@ozlabs.org Impact: fix to module check in making nops in dynamic ftrace for PPC Paul Mackerras pointed out that the mod test in ftrace_make_nop looks wrong. It is, but it did not trigger because the logic to ftrace just happens to miss the bad case. When ftrace first changes all the calls to mcount into nops, it passes in the "mod" parameter, and the rec->arch.mod is NULL. This case assigns the rec->arch.mod to mod and succeeds. From then on, ftrace will pass in a NULL for mod and the check if mod and rec->arch.mod is the same is skipped. The failure of the current test may produce a false positive failuer, which will cause ftrace to shutdown even if the code was correct. This patch fixes the test. Reported-by: Paul Mackerras Signed-off-by: Steven Rostedt --- arch/powerpc/kernel/ftrace.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/powerpc/kernel/ftrace.c b/arch/powerpc/kernel/ftrace.c index 918a5d2..81e338c 100644 --- a/arch/powerpc/kernel/ftrace.c +++ b/arch/powerpc/kernel/ftrace.c @@ -354,10 +354,13 @@ int ftrace_make_nop(struct module *mod, } rec->arch.mod = mod; } else if (mod) { - printk(KERN_ERR - "Record mod %p not equal to passed in mod %p\n", - rec->arch.mod, mod); - return -EINVAL; + if (mod != rec->arch.mod) { + printk(KERN_ERR + "Record mod %p not equal to passed in mod %p\n", + rec->arch.mod, mod); + return -EINVAL; + } + /* nothing to do if mod == rec->arch.mod */ } else mod = rec->arch.mod;