From patchwork Tue Jul 10 00:10:39 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9907 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 7440823E01 for ; Tue, 10 Jul 2012 00:13:07 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 43DF2A18102 for ; Tue, 10 Jul 2012 00:13:07 +0000 (UTC) Received: by yenq6 with SMTP id q6so11476663yen.11 for ; Mon, 09 Jul 2012 17:13:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=LNqZbNwAK/+ZkkDS3zr2eUa3AnOEliJts6IDY8p+ez0=; b=HdVLl0kNjJwEoKtTSAfPZ+KlSBL1okdJw6HJmPpfwgIE2g3qBmYHbmzllWkEMVbVMw ivugML8kR60/QwxldzvQjQxqu+ROYGupYnzK86iMVtaLVZYIkF6uUFzzlpbe8tqfHdzn 7o+aPGRgk4tNLjpKXxCeQQ+PDdsZTIhJdSKgP0M89LadsvXJYnrzZR/KmVrPSPrCC+DB seSJomxRD7Gl97UBrcKnDy2w2XUFEGeHjYtGBh5IA8m6A7pXVyCvqzRkGDGPz5vEse08 uVZhCT3pHhKOTSfdfWNy2zHGMivBILVd9d37MKcWCf7e37ZECaldT4SeDztJCpvc10xJ C3Fg== Received: by 10.42.68.65 with SMTP id w1mr3154606ici.57.1341879186496; Mon, 09 Jul 2012 17:13:06 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.24.148 with SMTP id v20csp42686ibb; Mon, 9 Jul 2012 17:13:05 -0700 (PDT) Received: by 10.68.209.133 with SMTP id mm5mr64209006pbc.153.1341879185242; Mon, 09 Jul 2012 17:13:05 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id rd4si34987071pbc.100.2012.07.09.17.13.04 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 17:13:05 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of anton.vorontsov@linaro.org) smtp.mail=anton.vorontsov@linaro.org Received: by pbbrr4 with SMTP id rr4so23733901pbb.37 for ; Mon, 09 Jul 2012 17:13:04 -0700 (PDT) Received: by 10.68.134.201 with SMTP id pm9mr65667894pbb.49.1341879184741; Mon, 09 Jul 2012 17:13:04 -0700 (PDT) Received: from localhost (c-71-204-165-222.hsd1.ca.comcast.net. [71.204.165.222]) by mx.google.com with ESMTPS id ru4sm28636620pbc.66.2012.07.09.17.13.02 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 Jul 2012 17:13:03 -0700 (PDT) From: Anton Vorontsov To: Greg Kroah-Hartman , Kees Cook , Colin Cross , Tony Luck , Steven Rostedt , Frederic Weisbecker , Ingo Molnar Cc: Arnd Bergmann , John Stultz , Shuah Khan , arve@android.com, Rebecca Schultz Zavin , Jesper Juhl , Randy Dunlap , Stephen Boyd , Thomas Meyer , Andrew Morton , Marco Stornelli , WANG Cong , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, linaro-kernel@lists.linaro.org, patches@linaro.org, kernel-team@android.com Subject: [PATCH 1/8] tracing: Fix initialization failure path in tracing_set_tracer() Date: Mon, 9 Jul 2012 17:10:39 -0700 Message-Id: <1341879046-5197-1-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120710001004.GA22744@lizard> References: <20120710001004.GA22744@lizard> X-Gm-Message-State: ALoCoQnf+8S1GnhYFhNU4AB2nEBVclBAiBG2A46j88/vrw+G4Pj+75LWnNASID3pT+6ZN1Qru8in If tracer->init() fails, current code will leave current_tracer pointing to an unusable tracer, which at best makes 'current_tracer' report inaccurate value. Fix the issue by pointing current_tracer to nop tracer, and only update current_tracer with the new one after all the initialization succeeds. Signed-off-by: Anton Vorontsov Acked-by: Steven Rostedt --- kernel/trace/trace.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 814ff30..954f7d7 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3183,10 +3183,10 @@ static int tracing_set_tracer(const char *buf) } destroy_trace_option_files(topts); - current_trace = t; + current_trace = &nop_trace; - topts = create_trace_option_files(current_trace); - if (current_trace->use_max_tr) { + topts = create_trace_option_files(t); + if (t->use_max_tr) { int cpu; /* we need to make per cpu buffer sizes equivalent */ for_each_tracing_cpu(cpu) { @@ -3206,6 +3206,7 @@ static int tracing_set_tracer(const char *buf) goto out; } + current_trace = t; trace_branch_enable(tr); out: mutex_unlock(&trace_types_lock);