From patchwork Sat Feb 20 11:32:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pingbo Wen X-Patchwork-Id: 62455 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp278978lbl; Sat, 20 Feb 2016 03:33:29 -0800 (PST) X-Received: by 10.98.68.194 with SMTP id m63mr24703926pfi.153.1455968009855; Sat, 20 Feb 2016 03:33:29 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 76si23458187pfb.3.2016.02.20.03.33.29; Sat, 20 Feb 2016 03:33:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2994628AbcBTLd1 (ORCPT + 30 others); Sat, 20 Feb 2016 06:33:27 -0500 Received: from mail-pf0-f172.google.com ([209.85.192.172]:35214 "EHLO mail-pf0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2994042AbcBTLdX (ORCPT ); Sat, 20 Feb 2016 06:33:23 -0500 Received: by mail-pf0-f172.google.com with SMTP id c10so67867627pfc.2 for ; Sat, 20 Feb 2016 03:33:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=UwjFG9z8xx3gc/zypxyvb+4LRxyWaf5DKjhOrcKolhE=; b=fV9pvbtoJWpPam+k6yPs1J8WSa7Bw692LtbJRhwjxGljm67m88hVjs2SSeziPHRfqG KULRbnrw88s+y9ovbDkb8ci0SsR226TnTSdgRUlAmpn7N5YsgWeKoIdv29rn95cECXOC Sz5JdV8ncmdBy1TuBFB7KfZp3QvP7JIyLnqts= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=UwjFG9z8xx3gc/zypxyvb+4LRxyWaf5DKjhOrcKolhE=; b=hfo8xjY/O2/QElVBicU+thuMs7FGt1/Jq5h2Mbd3ucopDUjYT3FiUw/nZI2EEjHDsb IqyFgW4KL2Q23ayxVQ7JwcFTwrLkAasypTAxGJ+FaPMTuQbQzWFPR1IuuAoTnOjULdTc Gp0Aj1rLBznWv68dJ4Lzji0t4rhvnW7aWejAH5PqB9fwNvquwK08vdZt809yps7zBChL /g2XGTrTRhC4CoPvdzoUp4/2KIRMUTLQ0YWqFLUzjbP96jiy9vIEml6dVq4j+JqPl/6Q roXZk5KhywSC3v5/zXyGrchKPD/8rZEum1fsdxELDFwAjeNskEra5BUOBR25tXZXknND eNyQ== X-Gm-Message-State: AG10YOT5preo9PGukYogRKYjeRZAn+pLpW++2jS+6JosFQe+3ydWO3ZE/h7vjXtYH88bKI7N X-Received: by 10.98.87.142 with SMTP id i14mr24501369pfj.63.1455968002761; Sat, 20 Feb 2016 03:33:22 -0800 (PST) Received: from localhost.localdomain ([103.26.122.10]) by smtp.gmail.com with ESMTPSA id bx1sm24163378pab.33.2016.02.20.03.33.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 20 Feb 2016 03:33:22 -0800 (PST) From: Pingbo Wen To: eas-dev@lists.linaro.org Cc: mturquette@baylibre.com, smuckle@linaro.org, linux-kernel@vger.kernel.org, Pingbo Wen Subject: [PATCH] cpufreq_sched: set governor_data before waking up kschedfreq Date: Sat, 20 Feb 2016 19:32:46 +0800 Message-Id: <1455967966-11911-1-git-send-email-pingbo.wen@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix null pointer dereference error liked below. This BUG can be easily re-produced by 'monkey --throttle 50' in android 6.0. Unable to handle kernel NULL pointer dereference at virtual address 00000010 [KERN Warning] check backtrace: CPU: 0 PID: 10714 Comm: kschedfreq:0 Tainted: Call trace: [] dump_backtrace+0x0/0x15c [] show_stack+0x10/0x1c [] dump_stack+0x74/0xb8 [] debug_locks_off+0x4c/0x7c [] oops_enter+0xc/0x28 [] die+0x2c/0x1a4 [] __do_kernel_fault.part.5+0x70/0x84 [] do_page_fault+0x344/0x348 [] do_translation_fault+0xbc/0xf0 [] do_mem_abort+0x38/0x9c [] el1_da+0x14/0x80 [] kthread+0xd4/0xec Signed-off-by: Pingbo Wen --- kernel/sched/cpufreq_sched.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 1.9.1 diff --git a/kernel/sched/cpufreq_sched.c b/kernel/sched/cpufreq_sched.c index e1d208e..93731ef 100644 --- a/kernel/sched/cpufreq_sched.c +++ b/kernel/sched/cpufreq_sched.c @@ -265,6 +265,8 @@ static int cpufreq_sched_policy_init(struct cpufreq_policy *policy) pr_debug("%s: throttle threshold = %u [ns]\n", __func__, gd->throttle_nsec); + policy->governor_data = gd; + if (cpufreq_driver_is_slow()) { cpufreq_driver_slow = true; gd->task = kthread_create(cpufreq_sched_thread, policy, @@ -281,7 +283,6 @@ static int cpufreq_sched_policy_init(struct cpufreq_policy *policy) init_irq_work(&gd->irq_work, cpufreq_sched_irq_work); } - policy->governor_data = gd; set_sched_freq(); return 0;