aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2014-12-23 18:23:35 -0500
committerZhang Rui <rui.zhang@intel.com>2014-12-23 21:37:43 -0500
commitcc3f71a41576ba014ba3b80d5d68b7faa90bfeef (patch)
treede4265e319737c35e2994b5c5694966917985b0c
parentf01bc8f37ec940caae8bf8b6e7169f7cc2b6877a (diff)
Thermal/int340x/processor_thermal: Fix memory leak
Address memory leak for buffer allocated with ACPI_ALLOCATE_BUFFER. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
-rw-r--r--drivers/thermal/int340x_thermal/processor_thermal_device.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/thermal/int340x_thermal/processor_thermal_device.c b/drivers/thermal/int340x_thermal/processor_thermal_device.c
index f83c55b09e52..31bb553aac26 100644
--- a/drivers/thermal/int340x_thermal/processor_thermal_device.c
+++ b/drivers/thermal/int340x_thermal/processor_thermal_device.c
@@ -127,6 +127,7 @@ static int proc_thermal_add(struct device *dev,
127 union acpi_object *elements, *ppcc; 127 union acpi_object *elements, *ppcc;
128 union acpi_object *p; 128 union acpi_object *p;
129 int i; 129 int i;
130 int ret;
130 131
131 adev = ACPI_COMPANION(dev); 132 adev = ACPI_COMPANION(dev);
132 133
@@ -137,16 +138,20 @@ static int proc_thermal_add(struct device *dev,
137 p = buf.pointer; 138 p = buf.pointer;
138 if (!p || (p->type != ACPI_TYPE_PACKAGE)) { 139 if (!p || (p->type != ACPI_TYPE_PACKAGE)) {
139 dev_err(dev, "Invalid PPCC data\n"); 140 dev_err(dev, "Invalid PPCC data\n");
140 return -EFAULT; 141 ret = -EFAULT;
142 goto free_buffer;
141 } 143 }
142 if (!p->package.count) { 144 if (!p->package.count) {
143 dev_err(dev, "Invalid PPCC package size\n"); 145 dev_err(dev, "Invalid PPCC package size\n");
144 return -EFAULT; 146 ret = -EFAULT;
147 goto free_buffer;
145 } 148 }
146 149
147 proc_priv = devm_kzalloc(dev, sizeof(*proc_priv), GFP_KERNEL); 150 proc_priv = devm_kzalloc(dev, sizeof(*proc_priv), GFP_KERNEL);
148 if (!proc_priv) 151 if (!proc_priv) {
149 return -ENOMEM; 152 ret = -ENOMEM;
153 goto free_buffer;
154 }
150 155
151 proc_priv->dev = dev; 156 proc_priv->dev = dev;
152 proc_priv->adev = adev; 157 proc_priv->adev = adev;
@@ -154,9 +159,10 @@ static int proc_thermal_add(struct device *dev,
154 for (i = 0; i < min((int)p->package.count - 1, 2); ++i) { 159 for (i = 0; i < min((int)p->package.count - 1, 2); ++i) {
155 elements = &(p->package.elements[i+1]); 160 elements = &(p->package.elements[i+1]);
156 if (elements->type != ACPI_TYPE_PACKAGE || 161 if (elements->type != ACPI_TYPE_PACKAGE ||
157 elements->package.count != 6) 162 elements->package.count != 6) {
158 return -EFAULT; 163 ret = -EFAULT;
159 164 goto free_buffer;
165 }
160 ppcc = elements->package.elements; 166 ppcc = elements->package.elements;
161 proc_priv->power_limits[i].index = ppcc[0].integer.value; 167 proc_priv->power_limits[i].index = ppcc[0].integer.value;
162 proc_priv->power_limits[i].min_uw = ppcc[1].integer.value; 168 proc_priv->power_limits[i].min_uw = ppcc[1].integer.value;
@@ -168,8 +174,13 @@ static int proc_thermal_add(struct device *dev,
168 174
169 *priv = proc_priv; 175 *priv = proc_priv;
170 176
171 return sysfs_create_group(&dev->kobj, 177 ret = sysfs_create_group(&dev->kobj,
172 &power_limit_attribute_group); 178 &power_limit_attribute_group);
179
180free_buffer:
181 kfree(buf.pointer);
182
183 return ret;
173} 184}
174 185
175void proc_thermal_remove(struct proc_thermal_device *proc_priv) 186void proc_thermal_remove(struct proc_thermal_device *proc_priv)