]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
regulator: bd718x7: Use kcalloc() instead of kzalloc()
authorQianfeng Rong <rongqianfeng@vivo.com>
Sun, 17 Aug 2025 14:23:27 +0000 (22:23 +0800)
committerMark Brown <broonie@kernel.org>
Mon, 18 Aug 2025 12:12:17 +0000 (13:12 +0100)
Replace calls of 'devm_kzalloc(dev, count * sizeof([type]), flags)'
with 'devm_kcalloc(dev, count, sizeof([type]), flags)' in
setup_feedback_loop() for safer memory allocation with built-in
overflow protection.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://patch.msgid.link/20250817142327.174531-1-rongqianfeng@vivo.com
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/bd718x7-regulator.c

index e803cc59d68a5c790c4278f68f5ba7d62e75773a..022d98f3c32a2dfa8f52cdd3c125d41bda8c91a2 100644 (file)
@@ -1598,7 +1598,7 @@ static int setup_feedback_loop(struct device *dev, struct device_node *np,
                if (desc->n_linear_ranges && desc->linear_ranges) {
                        struct linear_range *new;
 
-                       new = devm_kzalloc(dev, desc->n_linear_ranges *
+                       new = devm_kcalloc(dev, desc->n_linear_ranges,
                                           sizeof(struct linear_range),
                                           GFP_KERNEL);
                        if (!new)