Skip to content

Commit 427fbe8

Browse files
committed
Merge branch 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal fixes from Zhang Rui: - fix NULL pointer dereference on module load/probe for int3403_thermal driver - fix an emergency shutdown issue on exynos thermal driver * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: thermal: exynos: Propagate error value from tmu_read() thermal: exynos: Reading temperature makes sense only when TMU is turned on thermal: int3403_thermal: Fix NULL pointer deref on module load / probe
2 parents 0d4cafd + 60abce9 commit 427fbe8

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

drivers/thermal/int340x_thermal/int3403_thermal.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,15 +194,14 @@ static int int3403_cdev_add(struct int3403_priv *priv)
194194
return -EFAULT;
195195
}
196196

197+
priv->priv = obj;
197198
obj->max_state = p->package.count - 1;
198199
obj->cdev =
199200
thermal_cooling_device_register(acpi_device_bid(priv->adev),
200201
priv, &int3403_cooling_ops);
201202
if (IS_ERR(obj->cdev))
202203
result = PTR_ERR(obj->cdev);
203204

204-
priv->priv = obj;
205-
206205
kfree(buf.pointer);
207206
/* TODO: add ACPI notification support */
208207

drivers/thermal/samsung/exynos_tmu.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@
185185
* @regulator: pointer to the TMU regulator structure.
186186
* @reg_conf: pointer to structure to register with core thermal.
187187
* @ntrip: number of supported trip points.
188+
* @enabled: current status of TMU device
188189
* @tmu_initialize: SoC specific TMU initialization method
189190
* @tmu_control: SoC specific TMU control method
190191
* @tmu_read: SoC specific TMU temperature read method
@@ -205,6 +206,7 @@ struct exynos_tmu_data {
205206
struct regulator *regulator;
206207
struct thermal_zone_device *tzd;
207208
unsigned int ntrip;
209+
bool enabled;
208210

209211
int (*tmu_initialize)(struct platform_device *pdev);
210212
void (*tmu_control)(struct platform_device *pdev, bool on);
@@ -398,6 +400,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
398400
mutex_lock(&data->lock);
399401
clk_enable(data->clk);
400402
data->tmu_control(pdev, on);
403+
data->enabled = on;
401404
clk_disable(data->clk);
402405
mutex_unlock(&data->lock);
403406
}
@@ -889,19 +892,24 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on)
889892
static int exynos_get_temp(void *p, int *temp)
890893
{
891894
struct exynos_tmu_data *data = p;
895+
int value, ret = 0;
892896

893-
if (!data || !data->tmu_read)
897+
if (!data || !data->tmu_read || !data->enabled)
894898
return -EINVAL;
895899

896900
mutex_lock(&data->lock);
897901
clk_enable(data->clk);
898902

899-
*temp = code_to_temp(data, data->tmu_read(data)) * MCELSIUS;
903+
value = data->tmu_read(data);
904+
if (value < 0)
905+
ret = value;
906+
else
907+
*temp = code_to_temp(data, value) * MCELSIUS;
900908

901909
clk_disable(data->clk);
902910
mutex_unlock(&data->lock);
903911

904-
return 0;
912+
return ret;
905913
}
906914

907915
#ifdef CONFIG_THERMAL_EMULATION

0 commit comments

Comments
 (0)