1
0

Merge tag 'thermal-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull thermal control updates from Rafael Wysocki:
 "These include one thermal core fix for an issue leading to a NULL
  pointer dereference, a similar fix for the int340x thermal driver
  (even though the issue may not actually occur in practice in this
  particular case), and a bunch of cleanups, mostly related to replacing
  kzalloc() with kcalloc() where applicable.

  Summary:

   - Delay exposing thermal zone sysfs interface to prevent user space
     from accessing thermal zones that have not been completely
     initialized yet (Lucas De Marchi)

   - Check a pointer against NULL early in int3402_thermal_probe() to
     avoid a potential NULL pointer dereference (Chenyuan Yang)

   - Use kcalloc() instead of kzalloc() in some places in the thermal
     control subsystem (Lukasz Luba, Ethan Carter Edwards)

   - Fix a spelling mistake in a comment in the thermal core (Colin Ian
     King)

   - Clean up variable initialization in int340x_thermal_zone_add()
     (Christophe JAILLET)"

* tag 'thermal-6.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  thermal: int340x: Add NULL check for adev
  thermal: core: Delay exposing sysfs interface
  thermal: core: Fix spelling mistake "Occurences" -> "Occurrences"
  thermal: intel: Clean up zone_trips[] initialization in int340x_thermal_zone_add()
  thermal: hisi: Use kcalloc() instead of kzalloc() with multiplication
  thermal: int340x: Use kcalloc() instead of kzalloc() with multiplication
  thermal: k3_j72xx_bandgap: Use kcalloc() instead of kzalloc()
  thermal/of: Use kcalloc() instead of kzalloc() with multiplication
  thermal/debugfs: replace kzalloc() with kcalloc() in thermal_debug_tz_add()
This commit is contained in:
Linus Torvalds
2025-03-25 15:13:31 -07:00
7 changed files with 23 additions and 20 deletions

View File

@@ -412,8 +412,8 @@ static int hi3660_thermal_probe(struct hisi_thermal_data *data)
data->nr_sensors = 1;
data->sensor = devm_kzalloc(dev, sizeof(*data->sensor) *
data->nr_sensors, GFP_KERNEL);
data->sensor = devm_kcalloc(dev, data->nr_sensors,
sizeof(*data->sensor), GFP_KERNEL);
if (!data->sensor)
return -ENOMEM;

View File

@@ -45,6 +45,9 @@ static int int3402_thermal_probe(struct platform_device *pdev)
struct int3402_thermal_data *d;
int ret;
if (!adev)
return -ENODEV;
if (!acpi_has_method(adev->handle, "_TMP"))
return -ENODEV;

View File

@@ -133,8 +133,8 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
if (ACPI_SUCCESS(status))
int34x_zone->aux_trip_nr = trip_cnt;
zone_trips = kzalloc(sizeof(*zone_trips) * (trip_cnt + INT340X_THERMAL_MAX_TRIP_COUNT),
GFP_KERNEL);
zone_trips = kcalloc(trip_cnt + INT340X_THERMAL_MAX_TRIP_COUNT,
sizeof(*zone_trips), GFP_KERNEL);
if (!zone_trips) {
ret = -ENOMEM;
goto err_trips_alloc;
@@ -143,7 +143,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
for (i = 0; i < trip_cnt; i++) {
zone_trips[i].type = THERMAL_TRIP_PASSIVE;
zone_trips[i].temperature = THERMAL_TEMP_INVALID;
zone_trips[i].flags |= THERMAL_TRIP_FLAG_RW_TEMP;
zone_trips[i].flags = THERMAL_TRIP_FLAG_RW_TEMP;
zone_trips[i].priv = THERMAL_INT_TO_TRIP_PRIV(i);
}

View File

@@ -460,13 +460,13 @@ static int k3_j72xx_bandgap_probe(struct platform_device *pdev)
goto err_alloc;
}
ref_table = kzalloc(sizeof(*ref_table) * TABLE_SIZE, GFP_KERNEL);
ref_table = kcalloc(TABLE_SIZE, sizeof(*ref_table), GFP_KERNEL);
if (!ref_table) {
ret = -ENOMEM;
goto err_alloc;
}
derived_table = devm_kzalloc(bgp->dev, sizeof(*derived_table) * TABLE_SIZE,
derived_table = devm_kcalloc(bgp->dev, TABLE_SIZE, sizeof(*derived_table),
GFP_KERNEL);
if (!derived_table) {
ret = -ENOMEM;

View File

@@ -1589,26 +1589,26 @@ thermal_zone_device_register_with_trips(const char *type,
tz->state = TZ_STATE_FLAG_INIT;
result = dev_set_name(&tz->device, "thermal_zone%d", tz->id);
if (result)
goto remove_id;
thermal_zone_device_init(tz);
result = thermal_zone_init_governor(tz);
if (result)
goto remove_id;
/* sys I/F */
/* Add nodes that are always present via .groups */
result = thermal_zone_create_device_groups(tz);
if (result)
goto remove_id;
result = dev_set_name(&tz->device, "thermal_zone%d", tz->id);
if (result) {
thermal_zone_destroy_device_groups(tz);
goto remove_id;
}
thermal_zone_device_init(tz);
result = device_register(&tz->device);
if (result)
goto release_device;
result = thermal_zone_init_governor(tz);
if (result)
goto unregister;
if (!tz->tzp || !tz->tzp->no_hwmon) {
result = thermal_add_hwmon_sysfs(tz);
if (result)

View File

@@ -319,7 +319,7 @@ static int cdev_tt_seq_show(struct seq_file *s, void *v)
int i = *(loff_t *)v;
if (!i)
seq_puts(s, "Transition\tOccurences\n");
seq_puts(s, "Transition\tOccurrences\n");
list_for_each_entry(entry, &transitions[i], node) {
/*
@@ -876,7 +876,7 @@ void thermal_debug_tz_add(struct thermal_zone_device *tz)
tz_dbg->tz = tz;
tz_dbg->trips_crossed = kzalloc(sizeof(int) * tz->num_trips, GFP_KERNEL);
tz_dbg->trips_crossed = kcalloc(tz->num_trips, sizeof(int), GFP_KERNEL);
if (!tz_dbg->trips_crossed) {
thermal_debugfs_remove_id(thermal_dbg);
return;

View File

@@ -107,7 +107,7 @@ static struct thermal_trip *thermal_of_trips_init(struct device_node *np, int *n
if (!count)
return NULL;
struct thermal_trip *tt __free(kfree) = kzalloc(sizeof(*tt) * count, GFP_KERNEL);
struct thermal_trip *tt __free(kfree) = kcalloc(count, sizeof(*tt), GFP_KERNEL);
if (!tt)
return ERR_PTR(-ENOMEM);