Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

irqchip/imx-intmux: Use struct_size() helper in devm_kzalloc()

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.

This code was detected with the help of Coccinelle and, audited and
fixed manually.

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20200616230923.GA24937@embeddedor

authored by

Gustavo A. R. Silva and committed by
Marc Zyngier
2f7a9bda 6eeb997a

+1 -2
+1 -2
drivers/irqchip/irq-imx-intmux.c
··· 210 210 return -EINVAL; 211 211 } 212 212 213 - data = devm_kzalloc(&pdev->dev, sizeof(*data) + 214 - channum * sizeof(data->irqchip_data[0]), GFP_KERNEL); 213 + data = devm_kzalloc(&pdev->dev, struct_size(data, irqchip_data, channum), GFP_KERNEL); 215 214 if (!data) 216 215 return -ENOMEM; 217 216