]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
cpufreq: interactive: fix memory leak
authorMark Kuo <mkuo@nvidia.com>
Tue, 6 Jan 2015 02:05:01 +0000 (10:05 +0800)
committerBharat Nihalani <bnihalani@nvidia.com>
Tue, 6 Jan 2015 05:51:43 +0000 (21:51 -0800)
Memory leak from "above_hispeed_delay" and "target_loads" can occur if
cpu exit is called after sysfs write. This change fixes the leak by
freeing the 2 allocated arrays upon CPUFREQ_GOV_POLICY_EXIT.

Bug 200053544

Change-Id: If5612f58b0f92d777bea234cdc350a539d6c2c45
Signed-off-by: Mark Kuo <mkuo@nvidia.com>
Reviewed-on: http://git-master/r/654639
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Shridhar Rasal <srasal@nvidia.com>
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>
drivers/cpufreq/cpufreq_interactive.c

index 666fcfced14ca4fc882eb547af4d2140b5968bb8..b69556b02d12738922a3faf5e8770708ba62b325 100644 (file)
@@ -2,7 +2,7 @@
  * drivers/cpufreq/cpufreq_interactive.c
  *
  * Copyright (C) 2010 Google, Inc.
- * Copyright (c) 2012-2014, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2012-2015, NVIDIA CORPORATION. All rights reserved.
  *
  * This software is licensed under the terms of the GNU General Public
  * License version 2, as published by the Free Software Foundation, and
@@ -1283,6 +1283,11 @@ static int cpufreq_governor_interactive(struct cpufreq_policy *policy,
                        sysfs_remove_group(get_governor_parent_kobj(policy),
                                        get_sysfs_attr());
                        common_tunables = NULL;
+                       if (tunables->above_hispeed_delay !=
+                               default_above_hispeed_delay)
+                               kfree(tunables->above_hispeed_delay);
+                       if (tunables->target_loads != default_target_loads)
+                               kfree(tunables->target_loads);
                        kfree(tunables);
                }