linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH][next] irqchip: Use struct_size() helper in devm_kzalloc()
@ 2020-06-16 23:09 Gustavo A. R. Silva
  2020-06-27 11:08 ` Marc Zyngier
  0 siblings, 1 reply; 2+ messages in thread
From: Gustavo A. R. Silva @ 2020-06-16 23:09 UTC (permalink / raw)
  To: Thomas Gleixner, Jason Cooper, Marc Zyngier, Shawn Guo,
	Sascha Hauer, Pengutronix Kernel Team, Fabio Estevam,
	NXP Linux Team
  Cc: linux-kernel, linux-arm-kernel, Gustavo A. R. Silva

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>
---
 drivers/irqchip/irq-imx-intmux.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/irqchip/irq-imx-intmux.c b/drivers/irqchip/irq-imx-intmux.c
index c27577c81126..54d8bb4fc5a1 100644
--- a/drivers/irqchip/irq-imx-intmux.c
+++ b/drivers/irqchip/irq-imx-intmux.c
@@ -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;
 
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] irqchip: Use struct_size() helper in devm_kzalloc()
  2020-06-16 23:09 [PATCH][next] irqchip: Use struct_size() helper in devm_kzalloc() Gustavo A. R. Silva
@ 2020-06-27 11:08 ` Marc Zyngier
  0 siblings, 0 replies; 2+ messages in thread
From: Marc Zyngier @ 2020-06-27 11:08 UTC (permalink / raw)
  To: Jason Cooper, Matthias Brugger, Bartosz Golaszewski,
	Thomas Gleixner, Fabio Estevam, Sascha Hauer,
	Pengutronix Kernel Team, Gustavo A. R. Silva, NXP Linux Team,
	Shawn Guo
  Cc: Andrew Perepech, linux-mediatek, Stephane Le Provost,
	linux-arm-kernel, Pedro Tsai, Bartosz Golaszewski, Fabien Parent,
	linux-kernel, Gustavo A. R. Silva

On Tue, 16 Jun 2020 18:09:23 -0500, Gustavo A. R. Silva wrote:
> 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.

Applied to irq/irqchip-5.9:

[1/1] irqchip/imx-intmux: Use struct_size() helper in devm_kzalloc()
      commit: 2f7a9bda42f74e1169fcd9ef55c8ade989ef8bba

Thanks,

	M.
-- 
Without deviation from the norm, progress is not possible.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-27 11:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-16 23:09 [PATCH][next] irqchip: Use struct_size() helper in devm_kzalloc() Gustavo A. R. Silva
2020-06-27 11:08 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).