Re: [PATCH v8 19/29] thermal/of: Remove of_thermal_get_crit_temp()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Daniel,

On 03.10.2022 11:25, Daniel Lezcano wrote:
> The generic version of of_thermal_get_crit_temp() can be used. Let's
> remove this ops which is pointless.
>
> Signed-off-by: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>

This patch breaks Exynos thermal driver as it introduces a NULL pointer 
dereference in exynos_tmu_initialize():

8<--- cut here ---
Unable to handle kernel NULL pointer dereference at virtual address 00000000
[00000000] *pgd=00000000
Internal error: Oops: 80000005 [#1] PREEMPT SMP ARM
Modules linked in:
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.0.0-rc1-00072-ge521efddb107 
#12941
Hardware name: Samsung Exynos (Flattened Device Tree)
dwc2 12480000.hsotg: new address 125
PC is at 0x0
LR is at exynos_tmu_initialize+0x4c/0x1e8
...
Process swapper/0 (pid: 1, stack limit = 0x(ptrval))
Stack: (0xf082dd78 to 0xf082e000)
...
  exynos_tmu_initialize from exynos_tmu_probe+0x2b0/0x728
  exynos_tmu_probe from platform_probe+0x5c/0xb8
  platform_probe from really_probe+0xe0/0x414
  really_probe from __driver_probe_device+0xa0/0x208
  __driver_probe_device from driver_probe_device+0x30/0xc0
  driver_probe_device from __driver_attach+0xf0/0x1f0
  __driver_attach from bus_for_each_dev+0x70/0xb0
  bus_for_each_dev from bus_add_driver+0x174/0x218
  bus_add_driver from driver_register+0x88/0x11c
  driver_register from do_one_initcall+0x64/0x380
  do_one_initcall from kernel_init_freeable+0x1c0/0x224
  kernel_init_freeable from kernel_init+0x18/0x12c
  kernel_init from ret_from_fork+0x14/0x2c
Exception stack(0xf082dfb0 to 0xf082dff8)
...
Code: bad PC value
---[ end trace 0000000000000000 ]---

If there is no replacement for tzd->ops->get_crit_temp(tzd, &temp), then 
please simply remove that call in exynos_tmu_initialize() to avoid 
breaking the initialization.

> ---
> drivers/thermal/thermal_of.c | 15 ---------------
> 1 file changed, 15 deletions(-)
>
> diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
> index 494e9c319541..bd872183e521 100644
> --- a/drivers/thermal/thermal_of.c
> +++ b/drivers/thermal/thermal_of.c
> @@ -19,20 +19,6 @@
> #include "thermal_core.h"
> -static int of_thermal_get_crit_temp(struct thermal_zone_device *tz,
> - int *temp)
> -{
> - int i;
> -
> - for (i = 0; i < tz->num_trips; i++)
> - if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) {
> - *temp = tz->trips[i].temperature;
> - return 0;
> - }
> -
> - return -EINVAL;
> -}
> -
> /*** functions parsing device tree nodes ***/
> static int of_find_trip_id(struct device_node *np, struct device_node 
> *trip)
> @@ -529,7 +515,6 @@ struct thermal_zone_device 
> *thermal_of_zone_register(struct device_node *sensor,
> goto out_kfree_trips;
> }
> - of_ops->get_crit_temp = of_ops->get_crit_temp ? : 
> of_thermal_get_crit_temp;
> of_ops->bind = thermal_of_bind;
> of_ops->unbind = thermal_of_unbind;

Best regards

-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland




[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux