pwm: sti: Use devm_kcalloc() instead of calculating the size for devm_kzalloc()
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Sun, 10 Mar 2024 11:00:58 +0000 (12:00 +0100)
committerUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Fri, 26 Apr 2024 19:29:17 +0000 (21:29 +0200)
Using a multiplication to calculate the size of an allocation isn't
recommended in case the mulitplication overflows. While the chance this
happens is low, preventing such an error is easy enough; so do that.

Link: https://lore.kernel.org/r/17062aef42e6677629a056e25c6916d8b6eaedeb.1710068192.git.u.kleine-koenig@pengutronix.de
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
drivers/pwm/pwm-sti.c

index e8fdf96d8cc4d11bfd43dfc2da68db60e9125cda..7a7d1c622a1798696eb7693f16863196fb9b9987 100644 (file)
@@ -613,7 +613,8 @@ static int sti_pwm_probe(struct platform_device *pdev)
                        return dev_err_probe(dev, PTR_ERR(pc->cpt_clk),
                                             "failed to get PWM capture clock\n");
 
-               pc->ddata = devm_kzalloc(dev, pc->cpt_num_devs * sizeof(*pc->ddata), GFP_KERNEL);
+               pc->ddata = devm_kcalloc(dev, pc->cpt_num_devs,
+                                        sizeof(*pc->ddata), GFP_KERNEL);
                if (!pc->ddata)
                        return -ENOMEM;
        }