thermal: hisi: Use kcalloc() instead of kzalloc() with multiplication
authorLukasz Luba <lukasz.luba@arm.com>
Mon, 24 Feb 2025 17:33:06 +0000 (17:33 +0000)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 26 Feb 2025 19:55:42 +0000 (20:55 +0100)
According to the latest recommendations, kcalloc() should be used
instead of kzalloc() with multiplication (which might overflow).

Switch to this new scheme and use more safe kcalloc().

No functional impact.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Link: https://patch.msgid.link/20250224173432.1946070-5-lukasz.luba@arm.com
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/hisi_thermal.c

index 7e918bd3f100245351d13f76479685909deb2f65..4307161533a78fe5f026976d3580b67a04ccfec7 100644 (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;