Commit c0143f68 authored by Uwe Kleine-König's avatar Uwe Kleine-König

pwm: sti: Use devm_kcalloc() instead of calculating the size for devm_kzalloc()

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.deSigned-off-by: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
parent 9e287e0c
...@@ -613,7 +613,8 @@ static int sti_pwm_probe(struct platform_device *pdev) ...@@ -613,7 +613,8 @@ static int sti_pwm_probe(struct platform_device *pdev)
return dev_err_probe(dev, PTR_ERR(pc->cpt_clk), return dev_err_probe(dev, PTR_ERR(pc->cpt_clk),
"failed to get PWM capture clock\n"); "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) if (!pc->ddata)
return -ENOMEM; return -ENOMEM;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment