]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
thermal/of: Use kcalloc() instead of kzalloc() with multiplication
authorLukasz Luba <lukasz.luba@arm.com>
Mon, 24 Feb 2025 17:33:03 +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-2-lukasz.luba@arm.com
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_of.c

index 5ab4ce4daaebdf0210d9b318ae17b3eb8a4bccaf..fb376bd4d95790bbaf8a198b28c980675296f037 100644 (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);