summaryrefslogtreecommitdiff
path: root/drivers/thermal/intel
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/thermal/intel
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'drivers/thermal/intel')
-rw-r--r--drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c6
-rw-r--r--drivers/thermal/intel/int340x_thermal/int3400_thermal.c10
-rw-r--r--drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c7
-rw-r--r--drivers/thermal/intel/intel_hfi.c6
-rw-r--r--drivers/thermal/intel/intel_quark_dts_thermal.c2
-rw-r--r--drivers/thermal/intel/intel_soc_dts_iosf.c2
-rw-r--r--drivers/thermal/intel/x86_pkg_temp_thermal.c5
7 files changed, 18 insertions, 20 deletions
diff --git a/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c b/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
index ce5d53be108b..d1876e76167a 100644
--- a/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
+++ b/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
@@ -89,7 +89,7 @@ int acpi_parse_trt(acpi_handle handle, int *trt_count, struct trt **trtp,
}
*trt_count = p->package.count;
- trts = kcalloc(*trt_count, sizeof(struct trt), GFP_KERNEL);
+ trts = kzalloc_objs(struct trt, *trt_count, GFP_KERNEL);
if (!trts) {
result = -ENOMEM;
goto end;
@@ -165,7 +165,7 @@ int acpi_parse_art(acpi_handle handle, int *art_count, struct art **artp,
/* ignore p->package.elements[0], as this is _ART Revision field */
*art_count = p->package.count - 1;
- arts = kcalloc(*art_count, sizeof(struct art), GFP_KERNEL);
+ arts = kzalloc_objs(struct art, *art_count, GFP_KERNEL);
if (!arts) {
result = -ENOMEM;
goto end;
@@ -253,7 +253,7 @@ static int acpi_parse_psvt(acpi_handle handle, int *psvt_count, struct psvt **ps
goto end;
}
- psvts = kcalloc(*psvt_count, sizeof(*psvts), GFP_KERNEL);
+ psvts = kzalloc_objs(*psvts, *psvt_count, GFP_KERNEL);
if (!psvts) {
result = -ENOMEM;
goto end;
diff --git a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
index 41d3bc3ed8a2..3a97718e2f5c 100644
--- a/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
+++ b/drivers/thermal/intel/int340x_thermal/int3400_thermal.c
@@ -382,8 +382,7 @@ static int evaluate_odvp(struct int3400_thermal_priv *priv)
if (priv->odvp == NULL) {
priv->odvp_count = obj->package.count;
- priv->odvp = kmalloc_array(priv->odvp_count, sizeof(int),
- GFP_KERNEL);
+ priv->odvp = kmalloc_objs(int, priv->odvp_count, GFP_KERNEL);
if (!priv->odvp) {
ret = -ENOMEM;
goto out_err;
@@ -391,9 +390,8 @@ static int evaluate_odvp(struct int3400_thermal_priv *priv)
}
if (priv->odvp_attrs == NULL) {
- priv->odvp_attrs = kcalloc(priv->odvp_count,
- sizeof(struct odvp_attr),
- GFP_KERNEL);
+ priv->odvp_attrs = kzalloc_objs(struct odvp_attr,
+ priv->odvp_count, GFP_KERNEL);
if (!priv->odvp_attrs) {
ret = -ENOMEM;
goto out_err;
@@ -563,7 +561,7 @@ static int int3400_thermal_probe(struct platform_device *pdev)
if (!adev)
return -ENODEV;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
index 3d9efe69d562..7db8fd86c4fd 100644
--- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
+++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c
@@ -123,7 +123,7 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
acpi_status status;
int i, ret;
- int34x_zone = kzalloc(sizeof(*int34x_zone), GFP_KERNEL);
+ int34x_zone = kzalloc_obj(*int34x_zone, GFP_KERNEL);
if (!int34x_zone)
return ERR_PTR(-ENOMEM);
@@ -133,8 +133,9 @@ 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 = kcalloc(trip_cnt + INT340X_THERMAL_MAX_TRIP_COUNT,
- sizeof(*zone_trips), GFP_KERNEL);
+ zone_trips = kzalloc_objs(*zone_trips,
+ trip_cnt + INT340X_THERMAL_MAX_TRIP_COUNT,
+ GFP_KERNEL);
if (!zone_trips) {
ret = -ENOMEM;
goto err_trips_alloc;
diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/intel_hfi.c
index 8a2f441cd2ec..5100ad1336ed 100644
--- a/drivers/thermal/intel/intel_hfi.c
+++ b/drivers/thermal/intel/intel_hfi.c
@@ -212,7 +212,7 @@ static void update_capabilities(struct hfi_instance *hfi_instance)
if (!cpu_count)
goto out;
- cpu_caps = kcalloc(cpu_count, sizeof(*cpu_caps), GFP_KERNEL);
+ cpu_caps = kzalloc_objs(*cpu_caps, cpu_count, GFP_KERNEL);
if (!cpu_caps)
goto out;
@@ -690,8 +690,8 @@ void __init intel_hfi_init(void)
* This allocation may fail. CPU hotplug callbacks must check
* for a null pointer.
*/
- hfi_instances = kcalloc(max_hfi_instances, sizeof(*hfi_instances),
- GFP_KERNEL);
+ hfi_instances = kzalloc_objs(*hfi_instances, max_hfi_instances,
+ GFP_KERNEL);
if (!hfi_instances)
return;
diff --git a/drivers/thermal/intel/intel_quark_dts_thermal.c b/drivers/thermal/intel/intel_quark_dts_thermal.c
index 89498eb29a89..38a0ae14b69d 100644
--- a/drivers/thermal/intel/intel_quark_dts_thermal.c
+++ b/drivers/thermal/intel/intel_quark_dts_thermal.c
@@ -336,7 +336,7 @@ static struct soc_sensor_entry *alloc_soc_dts(void)
int err;
u32 out;
- aux_entry = kzalloc(sizeof(*aux_entry), GFP_KERNEL);
+ aux_entry = kzalloc_obj(*aux_entry, GFP_KERNEL);
if (!aux_entry) {
err = -ENOMEM;
return ERR_PTR(-ENOMEM);
diff --git a/drivers/thermal/intel/intel_soc_dts_iosf.c b/drivers/thermal/intel/intel_soc_dts_iosf.c
index ea87439fe7a9..78123107ac06 100644
--- a/drivers/thermal/intel/intel_soc_dts_iosf.c
+++ b/drivers/thermal/intel/intel_soc_dts_iosf.c
@@ -320,7 +320,7 @@ intel_soc_dts_iosf_init(enum intel_soc_dts_interrupt_type intr_type,
if (tj_max < 0)
return ERR_PTR(tj_max);
- sensors = kzalloc(sizeof(*sensors), GFP_KERNEL);
+ sensors = kzalloc_obj(*sensors, GFP_KERNEL);
if (!sensors)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/thermal/intel/x86_pkg_temp_thermal.c b/drivers/thermal/intel/x86_pkg_temp_thermal.c
index aab5f9fca9c3..64cc0361d440 100644
--- a/drivers/thermal/intel/x86_pkg_temp_thermal.c
+++ b/drivers/thermal/intel/x86_pkg_temp_thermal.c
@@ -335,7 +335,7 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
return tj_max;
tj_max *= 1000;
- zonedev = kzalloc(sizeof(*zonedev), GFP_KERNEL);
+ zonedev = kzalloc_obj(*zonedev, GFP_KERNEL);
if (!zonedev)
return -ENOMEM;
@@ -492,8 +492,7 @@ static int __init pkg_temp_thermal_init(void)
return -ENODEV;
max_id = topology_max_packages() * topology_max_dies_per_package();
- zones = kcalloc(max_id, sizeof(struct zone_device *),
- GFP_KERNEL);
+ zones = kzalloc_objs(struct zone_device *, max_id, GFP_KERNEL);
if (!zones)
return -ENOMEM;