diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-05-12 13:58:57 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-05-12 13:58:57 -0400 |
commit | 427fbe89261d8f11cd20b5a4ba94e977061f69d6 (patch) | |
tree | 2372e38929f4de3d900fd843d133e24c346e2f96 | |
parent | 0d4cafd12f4c67a3cce83fd0dd2e416080900615 (diff) | |
parent | 60abce9f43d812dfec6687a10ca30be380f6f97a (diff) |
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
-rw-r--r-- | drivers/thermal/int340x_thermal/int3403_thermal.c | 3 | ||||
-rw-r--r-- | drivers/thermal/samsung/exynos_tmu.c | 14 |
2 files changed, 12 insertions, 5 deletions
diff --git a/drivers/thermal/int340x_thermal/int3403_thermal.c b/drivers/thermal/int340x_thermal/int3403_thermal.c index 8a7f24dd9315..0c19fcd56a0d 100644 --- a/drivers/thermal/int340x_thermal/int3403_thermal.c +++ b/drivers/thermal/int340x_thermal/int3403_thermal.c | |||
@@ -194,6 +194,7 @@ static int int3403_cdev_add(struct int3403_priv *priv) | |||
194 | return -EFAULT; | 194 | return -EFAULT; |
195 | } | 195 | } |
196 | 196 | ||
197 | priv->priv = obj; | ||
197 | obj->max_state = p->package.count - 1; | 198 | obj->max_state = p->package.count - 1; |
198 | obj->cdev = | 199 | obj->cdev = |
199 | thermal_cooling_device_register(acpi_device_bid(priv->adev), | 200 | thermal_cooling_device_register(acpi_device_bid(priv->adev), |
@@ -201,8 +202,6 @@ static int int3403_cdev_add(struct int3403_priv *priv) | |||
201 | if (IS_ERR(obj->cdev)) | 202 | if (IS_ERR(obj->cdev)) |
202 | result = PTR_ERR(obj->cdev); | 203 | result = PTR_ERR(obj->cdev); |
203 | 204 | ||
204 | priv->priv = obj; | ||
205 | |||
206 | kfree(buf.pointer); | 205 | kfree(buf.pointer); |
207 | /* TODO: add ACPI notification support */ | 206 | /* TODO: add ACPI notification support */ |
208 | 207 | ||
diff --git a/drivers/thermal/samsung/exynos_tmu.c b/drivers/thermal/samsung/exynos_tmu.c index ed805c7c5ace..ac83f721db24 100644 --- a/drivers/thermal/samsung/exynos_tmu.c +++ b/drivers/thermal/samsung/exynos_tmu.c | |||
@@ -185,6 +185,7 @@ | |||
185 | * @regulator: pointer to the TMU regulator structure. | 185 | * @regulator: pointer to the TMU regulator structure. |
186 | * @reg_conf: pointer to structure to register with core thermal. | 186 | * @reg_conf: pointer to structure to register with core thermal. |
187 | * @ntrip: number of supported trip points. | 187 | * @ntrip: number of supported trip points. |
188 | * @enabled: current status of TMU device | ||
188 | * @tmu_initialize: SoC specific TMU initialization method | 189 | * @tmu_initialize: SoC specific TMU initialization method |
189 | * @tmu_control: SoC specific TMU control method | 190 | * @tmu_control: SoC specific TMU control method |
190 | * @tmu_read: SoC specific TMU temperature read method | 191 | * @tmu_read: SoC specific TMU temperature read method |
@@ -205,6 +206,7 @@ struct exynos_tmu_data { | |||
205 | struct regulator *regulator; | 206 | struct regulator *regulator; |
206 | struct thermal_zone_device *tzd; | 207 | struct thermal_zone_device *tzd; |
207 | unsigned int ntrip; | 208 | unsigned int ntrip; |
209 | bool enabled; | ||
208 | 210 | ||
209 | int (*tmu_initialize)(struct platform_device *pdev); | 211 | int (*tmu_initialize)(struct platform_device *pdev); |
210 | void (*tmu_control)(struct platform_device *pdev, bool on); | 212 | void (*tmu_control)(struct platform_device *pdev, bool on); |
@@ -398,6 +400,7 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on) | |||
398 | mutex_lock(&data->lock); | 400 | mutex_lock(&data->lock); |
399 | clk_enable(data->clk); | 401 | clk_enable(data->clk); |
400 | data->tmu_control(pdev, on); | 402 | data->tmu_control(pdev, on); |
403 | data->enabled = on; | ||
401 | clk_disable(data->clk); | 404 | clk_disable(data->clk); |
402 | mutex_unlock(&data->lock); | 405 | mutex_unlock(&data->lock); |
403 | } | 406 | } |
@@ -889,19 +892,24 @@ static void exynos7_tmu_control(struct platform_device *pdev, bool on) | |||
889 | static int exynos_get_temp(void *p, int *temp) | 892 | static int exynos_get_temp(void *p, int *temp) |
890 | { | 893 | { |
891 | struct exynos_tmu_data *data = p; | 894 | struct exynos_tmu_data *data = p; |
895 | int value, ret = 0; | ||
892 | 896 | ||
893 | if (!data || !data->tmu_read) | 897 | if (!data || !data->tmu_read || !data->enabled) |
894 | return -EINVAL; | 898 | return -EINVAL; |
895 | 899 | ||
896 | mutex_lock(&data->lock); | 900 | mutex_lock(&data->lock); |
897 | clk_enable(data->clk); | 901 | clk_enable(data->clk); |
898 | 902 | ||
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; | ||
900 | 908 | ||
901 | clk_disable(data->clk); | 909 | clk_disable(data->clk); |
902 | mutex_unlock(&data->lock); | 910 | mutex_unlock(&data->lock); |
903 | 911 | ||
904 | return 0; | 912 | return ret; |
905 | } | 913 | } |
906 | 914 | ||
907 | #ifdef CONFIG_THERMAL_EMULATION | 915 | #ifdef CONFIG_THERMAL_EMULATION |