From patchwork Wed Jun 18 07:40:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 32112 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f72.google.com (mail-oa0-f72.google.com [209.85.219.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 12331206A0 for ; Wed, 18 Jun 2014 07:40:57 +0000 (UTC) Received: by mail-oa0-f72.google.com with SMTP id eb12sf3425630oac.7 for ; Wed, 18 Jun 2014 00:40:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mime-version:in-reply-to:references :date:message-id:subject:from:to:cc:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=/8pEE6OHwo1dAjPPyS5uuoDa4jLEAdN24IOvKq/ePG8=; b=Ms6JsEVdTLV9/4nB/WWxdVPGFZQplXTtKE/jyB/UkxfuSl0BfFSE0MMK0SC3ln4JWA 2L1kczI/SrHhShdmgprKXALa01EbivdnrjRkuhWZ5gI4LkzueV0BTmLZOOq1cY1fIp/Z qjr0Nw1ATzlFCCJ/COrp0lxb99DFsXFVPMFTo9nuiDQ2qKDheplNStBmvGbeNDrgAD6M hCRGD5AYCqivQRelQ0TUxu7/PMPi25M9uzMPYZg73yH/wX2RMXzrrLFyRy6jQ1THPSv4 srSTX8dX9FHFkZXZ7YtyTIwXYeTM/fRopRIPVdYQg9OpL/K2FiQsTR9un1f1EoDUSCgo KfKg== X-Gm-Message-State: ALoCoQnOZe9TeQWUs4TXXgC/YsOmPLnZqnt75xnPYqPjTq+L3C345Qp19Bd6jO9lC+5Ic0iXep6s X-Received: by 10.182.28.136 with SMTP id b8mr98872obh.19.1403077256654; Wed, 18 Jun 2014 00:40:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.24.181 with SMTP id 50ls5159123qgr.92.gmail; Wed, 18 Jun 2014 00:40:56 -0700 (PDT) X-Received: by 10.58.23.7 with SMTP id i7mr104693vef.57.1403077256514; Wed, 18 Jun 2014 00:40:56 -0700 (PDT) Received: from mail-ve0-f179.google.com (mail-ve0-f179.google.com [209.85.128.179]) by mx.google.com with ESMTPS id nc1si508073veb.6.2014.06.18.00.40.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 18 Jun 2014 00:40:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.179 as permitted sender) client-ip=209.85.128.179; Received: by mail-ve0-f179.google.com with SMTP id sa20so432359veb.10 for ; Wed, 18 Jun 2014 00:40:56 -0700 (PDT) X-Received: by 10.58.68.129 with SMTP id w1mr108139vet.49.1403077256400; Wed, 18 Jun 2014 00:40:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.54.6 with SMTP id vs6csp263947vcb; Wed, 18 Jun 2014 00:40:55 -0700 (PDT) X-Received: by 10.68.215.3 with SMTP id oe3mr250271pbc.109.1403077255612; Wed, 18 Jun 2014 00:40:55 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id zv1si1264059pac.119.2014.06.18.00.40.55 for ; Wed, 18 Jun 2014 00:40:55 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965122AbaFRHko (ORCPT + 26 others); Wed, 18 Jun 2014 03:40:44 -0400 Received: from mail-oa0-f49.google.com ([209.85.219.49]:39133 "EHLO mail-oa0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965070AbaFRHkl (ORCPT ); Wed, 18 Jun 2014 03:40:41 -0400 Received: by mail-oa0-f49.google.com with SMTP id i7so973340oag.8 for ; Wed, 18 Jun 2014 00:40:40 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.20.169 with SMTP id o9mr182128obe.59.1403077240684; Wed, 18 Jun 2014 00:40:40 -0700 (PDT) Received: by 10.182.45.196 with HTTP; Wed, 18 Jun 2014 00:40:40 -0700 (PDT) In-Reply-To: <1403050362-20809-1-git-send-email-aplattner@nvidia.com> References: <1403050362-20809-1-git-send-email-aplattner@nvidia.com> Date: Wed, 18 Jun 2014 13:10:40 +0530 Message-ID: Subject: Re: [PATCH] cpufreq: unlock when failing cpufreq_update_policy() From: Viresh Kumar To: Aaron Plattner Cc: "linux-pm@vger.kernel.org" , Linux Kernel Mailing List , "Rafael J. Wysocki" Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: viresh.kumar@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On 18 June 2014 05:42, Aaron Plattner wrote: > Commit bd0fa9bb455d introduced a failure path to cpufreq_update_policy() if > cpufreq_driver->get(cpu) returns NULL. However, it jumps to the 'no_policy' > label, which exits without unlocking any of the locks the function acquired > earlier. This causes later calls into cpufreq to hang. > > Fix this by creating a new 'unlock' label and jumping to that instead. > > Fixes: bd0fa9bb455d ("cpufreq: Return error if ->get() failed in cpufreq_update_policy()") > Link: https://devtalk.nvidia.com/default/topic/751903/kernel-3-15-and-nv-drivers-337-340-failed-to-initialize-the-nvidia-kernel-module-gtx-550-ti-/ > Cc: Viresh Kumar > Cc: Rafael J. Wysocki > Signed-off-by: Aaron Plattner > --- > I haven't reproduced this problem so I couldn't test it, but the bug and its > solution seem obvious enough. > > drivers/cpufreq/cpufreq.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index aed2b0cb83dc..5b6d04f3b9ea 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -2264,7 +2264,7 @@ int cpufreq_update_policy(unsigned int cpu) > new_policy.cur = cpufreq_driver->get(cpu); > if (WARN_ON(!new_policy.cur)) { > ret = -EIO; > - goto no_policy; > + goto unlock; > } > > if (!policy->cur) { > @@ -2279,6 +2279,7 @@ int cpufreq_update_policy(unsigned int cpu) > > ret = cpufreq_set_policy(policy, &new_policy); > > +unlock: > up_write(&policy->rwsem); > > cpufreq_cpu_put(policy); Hmm, yes we do have a problem here but the code became a bit ugly now.. Can you please consider this diff instead? --- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index aed2b0c..6caced5 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2242,10 +2242,8 @@ int cpufreq_update_policy(unsigned int cpu) struct cpufreq_policy new_policy; int ret; - if (!policy) { - ret = -ENODEV; - goto no_policy; - } + if (!policy) + return = -ENODEV; down_write(&policy->rwsem); @@ -2279,10 +2277,10 @@ int cpufreq_update_policy(unsigned int cpu) ret = cpufreq_set_policy(policy, &new_policy); +no_policy: up_write(&policy->rwsem); cpufreq_cpu_put(policy); -no_policy: return ret; } EXPORT_SYMBOL(cpufreq_update_policy);