From c0143f68919e6e36a4fa8816ddb49d266f3b21de Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Sun, 10 Mar 2024 12:00:58 +0100 Subject: [PATCH] pwm: sti: Use devm_kcalloc() instead of calculating the size for devm_kzalloc() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- drivers/pwm/pwm-sti.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pwm/pwm-sti.c b/drivers/pwm/pwm-sti.c index e8fdf96d8cc4d..7a7d1c622a179 100644 --- a/drivers/pwm/pwm-sti.c +++ b/drivers/pwm/pwm-sti.c @@ -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; } -- 2.30.2