irqchip/imx-intmux: Use struct_size() helper in devm_kzalloc()
authorGustavo A. R. Silva <gustavoars@kernel.org>
Tue, 16 Jun 2020 23:09:23 +0000 (18:09 -0500)
committerMarc Zyngier <maz@kernel.org>
Sat, 27 Jun 2020 10:55:29 +0000 (11:55 +0100)
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
drivers/irqchip/irq-imx-intmux.c

index c27577c811268bc45f33807f4e657d17efba4ff8..54d8bb4fc5a1112d8ec33f03168bcc5ea0c58f95 100644 (file)
@@ -210,8 +210,7 @@ static int imx_intmux_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       data = devm_kzalloc(&pdev->dev, sizeof(*data) +
-                           channum * sizeof(data->irqchip_data[0]), GFP_KERNEL);
+       data = devm_kzalloc(&pdev->dev, struct_size(data, irqchip_data, channum), GFP_KERNEL);
        if (!data)
                return -ENOMEM;