cpuquiet: move back cpuquiet_lock
authorJubeom Kim <jubeomk@nvidia.com>
Fri, 29 Nov 2013 07:37:28 +0000 (16:37 +0900)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 18 May 2015 08:07:11 +0000 (16:07 +0800)
Moved cpuquiet_lock to the back of cpuquiet_switch_governor().
cpuquiet_switch_governor() has to be protected by cpuquiet_lock.
In the runnable cpuquiet_governor case, it can occur a kernel panic or BUG_ON
because schedule_work() and INIT_WORK() can be performed at the same time.

Bug 1410816

Change-Id: I6d3d69bd8896e5425a762cbc4a58343a319edf29
Signed-off-by: Jubeom Kim <jubeomk@nvidia.com>
(cherry picked from commit 8502d0b7c057f96b7cd0495b49e37fc968d4bf8a)
Reviewed-on: http://git-master/r/337335
Reviewed-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Tested-by: Sai Gurrappadi <sgurrappadi@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>
drivers/cpuquiet/sysfs.c

index c3ae097bd56dcdced61c7590f2145d35afa3f487..3c1422680bbe473310b66c8e162adb90319254dc 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012 NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2012-2013 NVIDIA CORPORATION.  All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -70,10 +70,10 @@ static ssize_t store_current_governor(const char *buf, size_t count)
 
        mutex_lock(&cpuquiet_lock);
        gov = cpuquiet_find_governor(name);
-       mutex_unlock(&cpuquiet_lock);
 
        if (gov)
                ret = cpuquiet_switch_governor(gov);
+       mutex_unlock(&cpuquiet_lock);
 
        if (ret)
                return ret;