From patchwork Tue Jun 26 23:23:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9632 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 D06F423F28 for ; Tue, 26 Jun 2012 23:25:43 +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 9F3BEA18890 for ; Tue, 26 Jun 2012 23:25:43 +0000 (UTC) Received: by mail-yx0-f180.google.com with SMTP id q6so526365yen.11 for ; Tue, 26 Jun 2012 16:25:43 -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=rgDJArLt3hihCX4zVlwG8ytw983kav8RmviUuqaCuKU=; b=JWDWz1LaixOtm+y29bkTUMyLxZiqrnX9/YOfrSKCtFveSeg0zHb0ypiIl7oEMsjwCP IQt/+DMKNdEXJL+XgF0pQIeRJLylXBJ/ZtIFe6fwGvY9z94tGRsJKOTP2mGowMUZGnjw 9PFSKHx0rykgpWAGqeC2IfJodgkOmm/kTd+6O9/W4VNSi64ZudK/YCdbQIHaQuTMfiXV l7tURsp/7kGvwhOIQyTBRDdJwjGXQhrMfQOI+pdPGyiHbdol/Zmcw/fOkCyjPKJGNtPq N/Rf/wHyTBEQb9HE9+QOVgTN4pqHjkjocNTdNkXJYfKVF04sFYeahrbLzu5nQmYf/QOM AtuQ== Received: by 10.42.155.73 with SMTP id t9mr9474631icw.48.1340753132593; Tue, 26 Jun 2012 16:25:32 -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 v20csp91702ibb; Tue, 26 Jun 2012 16:25:32 -0700 (PDT) Received: by 10.68.225.170 with SMTP id rl10mr56902213pbc.13.1340753131715; Tue, 26 Jun 2012 16:25:31 -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 qr7si17761053pbc.10.2012.06.26.16.25.31 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jun 2012 16:25:31 -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 rr4so846637pbb.37 for ; Tue, 26 Jun 2012 16:25:31 -0700 (PDT) Received: by 10.68.242.71 with SMTP id wo7mr11023798pbc.153.1340753131163; Tue, 26 Jun 2012 16:25:31 -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 tk1sm13210189pbc.8.2012.06.26.16.25.29 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 26 Jun 2012 16:25:30 -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/7] tracing: Fix initialization failure path in tracing_set_tracer() Date: Tue, 26 Jun 2012 16:23:23 -0700 Message-Id: <1340753009-12483-1-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120626232210.GA11549@lizard> References: <20120626232210.GA11549@lizard> X-Gm-Message-State: ALoCoQlrRk4i8Xq5+G2dn7ITrSnxKrCBin0W2CBWLzal5qdGrQi57yYYjv94pWr6VrWEiufT8D+A 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 a7fa070..7647d33 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);