From patchwork Sat May 26 13:39:05 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9002 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 92E5423F00 for ; Sat, 26 May 2012 13:41:14 +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 585BAA18441 for ; Sat, 26 May 2012 13:41:14 +0000 (UTC) Received: by yenq6 with SMTP id q6so1080455yen.11 for ; Sat, 26 May 2012 06:41:13 -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=iaX5MChAZ6vPZAukkQSMSMG9A7ni1c6Ra7Smyjqli3Q=; b=DeAI+9wqcOpfugVgo35LnnORKecIEoeRL0Rq6+NUBH3fk07tL0C4Q1whAZGz9uSNnT aBt1x5tnzcFTPojYIS2j4r4uZxBYF+e/q+ygugup42wH67/UcjS5MQa1ZQSWk7qb9VSp 1Slc4cE28KBaxIYHkLf1iGqTueZn/Ufm+VDxQjqg5lkbttP60ByuV1hF93Mmx1Y76sGW vv+HR5jQLHZZDIjieOd4bJnp+M9OCR7oHvcgoJ5wqQcBidgEMvluItpybn7VDyCIW02t 9HjYchbRAwZCu3TEq+gpH5fYCCMejSt1OesJl2Bm7yuknf/fI63/zZm2zO6AU3bhOCbs s/fg== Received: by 10.50.222.202 with SMTP id qo10mr1035126igc.0.1338039673546; Sat, 26 May 2012 06:41:13 -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 v20csp87061ibb; Sat, 26 May 2012 06:41:13 -0700 (PDT) Received: by 10.68.132.166 with SMTP id ov6mr8249349pbb.24.1338039672866; Sat, 26 May 2012 06:41:12 -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 sl1si12145431pbc.84.2012.05.26.06.41.12 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 May 2012 06:41:12 -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 rr4so3306520pbb.37 for ; Sat, 26 May 2012 06:41:12 -0700 (PDT) Received: by 10.68.132.199 with SMTP id ow7mr7653631pbb.144.1338039672501; Sat, 26 May 2012 06:41:12 -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 b10sm12579648pbr.46.2012.05.26.06.41.09 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 26 May 2012 06:41:11 -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/5] tracing: Fix initialization failure path in tracing_set_tracer() Date: Sat, 26 May 2012 06:39:05 -0700 Message-Id: <1338039549-24498-1-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.9.2 In-Reply-To: <20120526133412.GA18001@lizard> References: <20120526133412.GA18001@lizard> X-Gm-Message-State: ALoCoQnBAoxVJyhzqk2RWqVMiqrMA4BKrmg3X6afUZMsj5KKniU71WkGyioFJZI3oXK8BMKC0dur 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 --- 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 68032c6..5cf7e67 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -3172,10 +3172,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) { @@ -3195,6 +3195,7 @@ static int tracing_set_tracer(const char *buf) goto out; } + current_trace = t; trace_branch_enable(tr); out: mutex_unlock(&trace_types_lock);