From patchwork Thu Oct 3 15:56:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 20800 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f71.google.com (mail-qe0-f71.google.com [209.85.128.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3A7DE25CAB for ; Thu, 3 Oct 2013 15:58:17 +0000 (UTC) Received: by mail-qe0-f71.google.com with SMTP id a11sf5476903qen.2 for ; Thu, 03 Oct 2013 08:58:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:in-reply-to:references :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=V6EqnfYKukF78wn9PEv+jjT2aNVwDPZXPqqIU0lpygk=; b=FLqBKeolVRvYZtnDdisJwumdAksSL7T1QMs+xYOCEhtG/X2PVlT4x+pgKkVNgv+XT4 CjDHiXdLHgUFdKB+6mIn52waxvlVOUu5flA+mRlBjJoI1AeqOAtm3k+IN9+M6HINsAYV bBnrkSHd4DaQr8iTVvv/GHPMUg5Z8c+Lh3Lcmgd5JcHHPRmTZujH1cWpH/GgzTwoMKnY +HAIA5jNCqP2ucU0RC/x3xn3yAXs0XfcjixcS1/Gi+Kv7ZMwARGW1s/82UBBKncuUSff 8hyTJBPmWS0Y7FnjsWuJIPc50LbVeE3ROR2/Yixmc9HzOeCjKqAIAM/jyb+OBvRV0OXo gmIQ== X-Received: by 10.58.220.136 with SMTP id pw8mr1440273vec.13.1380815897016; Thu, 03 Oct 2013 08:58:17 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.86.161 with SMTP id q1ls975727qez.13.gmail; Thu, 03 Oct 2013 08:58:16 -0700 (PDT) X-Received: by 10.52.37.69 with SMTP id w5mr1075002vdj.32.1380815896864; Thu, 03 Oct 2013 08:58:16 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id st7si1889017vdc.3.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 08:58:16 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id jx11so1820309veb.35 for ; Thu, 03 Oct 2013 08:58:16 -0700 (PDT) X-Gm-Message-State: ALoCoQm9bUeFEEeR0/0d0RSWAxYodokM63cnRHAI6ahGVOG9+S7t7aZjwMjs/aMKIRhMDPjjZFKU X-Received: by 10.221.44.136 with SMTP id ug8mr7970868vcb.13.1380815896754; Thu, 03 Oct 2013 08:58:16 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp189230vcz; Thu, 3 Oct 2013 08:58:16 -0700 (PDT) X-Received: by 10.66.162.167 with SMTP id yb7mr10428513pab.16.1380815895853; Thu, 03 Oct 2013 08:58:15 -0700 (PDT) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id to1si6806701pab.254.1969.12.31.16.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 03 Oct 2013 08:58:15 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of viresh.kumar@linaro.org) client-ip=209.85.160.46; Received: by mail-pb0-f46.google.com with SMTP id rq2so2663034pbb.33 for ; Thu, 03 Oct 2013 08:58:15 -0700 (PDT) X-Received: by 10.66.147.230 with SMTP id tn6mr10232852pab.135.1380815895422; Thu, 03 Oct 2013 08:58:15 -0700 (PDT) Received: from localhost ([122.167.152.64]) by mx.google.com with ESMTPSA id vz4sm11573016pab.11.1969.12.31.16.00.00 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 03 Oct 2013 08:58:14 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl, daniel.lezcano@linaro.org Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Viresh Kumar Subject: [PATCH V2 11/16] cpuidle: call cpuidle_get_driver() from after taking cpuidle_driver_lock Date: Thu, 3 Oct 2013 21:26:50 +0530 Message-Id: X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e In-Reply-To: References: In-Reply-To: References: X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , cpuidle_driver_lock is taken correctly at most of the places but at few places calls to cpuidle_get_driver() are done from outside of this lock. Fix them by calling cpuidle_get_driver() after taking cpuidle_driver_lock. Acked-by: Daniel Lezcano Signed-off-by: Viresh Kumar --- drivers/cpuidle/driver.c | 3 ++- drivers/cpuidle/sysfs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 58077a9..662d934 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -338,10 +338,11 @@ struct cpuidle_driver *cpuidle_driver_ref(void) */ void cpuidle_driver_unref(void) { - struct cpuidle_driver *drv = cpuidle_get_driver(); + struct cpuidle_driver *drv; spin_lock(&cpuidle_driver_lock); + drv = cpuidle_get_driver(); if (drv && !WARN_ON(drv->refcnt <= 0)) drv->refcnt--; diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c index 8739cc0..a022393 100644 --- a/drivers/cpuidle/sysfs.c +++ b/drivers/cpuidle/sysfs.c @@ -52,9 +52,10 @@ static ssize_t show_current_driver(struct device *dev, char *buf) { ssize_t ret; - struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver(); + struct cpuidle_driver *cpuidle_driver; spin_lock(&cpuidle_driver_lock); + cpuidle_driver = cpuidle_get_driver(); if (cpuidle_driver) ret = sprintf(buf, "%s\n", cpuidle_driver->name); else