From patchwork Fri Jun 15 17:08:26 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Vorontsov X-Patchwork-Id: 9322 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 400BA23E5A for ; Fri, 15 Jun 2012 17:10: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 09266A18174 for ; Fri, 15 Jun 2012 17:10:42 +0000 (UTC) Received: by yenq6 with SMTP id q6so2860682yen.11 for ; Fri, 15 Jun 2012 10:10:42 -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=/ps0lHREW4o9cFF6kVM4R4bxVvVnoSPEq9IeE+qkOxc=; b=F12sIg8g/2s3M+CDyg566zClY9fKg9h6bn533AG+5fPV3av4MwqmUbW/QmBbZpc2Zz LKKZtyuKeUipN88BL9JAPm5FZ3r1KO6uSi+XEfHEWtKuxYaLEZAc4kHsVUem6lCq3iJg d6JJ22e5WsjEM87uR64BPIZ8+44Dm/4kgPWFA5li8fd/2VE18jIG4hjGDE4bndTvBpNR OX+RXCAz0/u5td0r16rKeE92Va/kcL68XZIscvfE1+ZsEYQlXvSo/gVj0NnTxn9Fe9LR t9DW/klC/m3Xi4NzPDysq8nq8y0n8uu6k6nGAGGv6ekyTQP1IilKXgg98LzP8YnsiUO9 HgzQ== Received: by 10.50.87.227 with SMTP id bb3mr2730883igb.57.1339780242224; Fri, 15 Jun 2012 10:10:42 -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 v20csp158946ibb; Fri, 15 Jun 2012 10:10:41 -0700 (PDT) Received: by 10.50.6.197 with SMTP id d5mr2747702iga.44.1339780241143; Fri, 15 Jun 2012 10:10:41 -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 rn8si8864071pbc.127.2012.06.15.10.10.40 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jun 2012 10:10:41 -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 rr4so6362705pbb.37 for ; Fri, 15 Jun 2012 10:10:40 -0700 (PDT) Received: by 10.68.220.10 with SMTP id ps10mr10098603pbc.105.1339780240859; Fri, 15 Jun 2012 10:10:40 -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 x1sm13813681pbp.50.2012.06.15.10.10.38 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Jun 2012 10:10:40 -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/6] tracing: Fix initialization failure path in tracing_set_tracer() Date: Fri, 15 Jun 2012 10:08:26 -0700 Message-Id: <1339780111-12075-1-git-send-email-anton.vorontsov@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20120615170659.GA4060@lizard> References: <20120615170659.GA4060@lizard> X-Gm-Message-State: ALoCoQlayie6zV6/t1ExJeVOLkswuhy5JpPqehLWXHGtaOFk+MlyCZutc6VUEBw0HEtqHPoMUYHa 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);