Commit e6ca59bb authored by Ethan Carter Edwards's avatar Ethan Carter Edwards Committed by Rafael J. Wysocki
Browse files

thermal/debugfs: replace kzalloc() with kcalloc() in thermal_debug_tz_add()

Work is under way to get rid of all multiplications from allocation
functions to prevent integer overflows [1].

Here the multiplication is obviously safe, but using kcalloc() is more
appropriate and improves readability.

This change has no effect on runtime behavior.

Link: https://github.com/KSPP/linux/issues/162

 [1]
Signed-off-by: default avatarEthan Carter Edwards <ethan@ethancedwards.com>
Link: https://patch.msgid.link/20250222-thermal_kcalloc-v1-1-9f7a747fbed7@ethancedwards.com


[ rjw: Changelog edits ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent d082ecbc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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;