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

thunderbolt: Use kcalloc

The advantage of kcalloc is, that will prevent integer overflows
which could result from the multiplication of number of elements
and size and it is also a bit nicer to read.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Acked-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Himangi Saraogi and committed by
Greg Kroah-Hartman
2a211f32 95b4ecbf

+4 -6
+4 -6
drivers/thunderbolt/nhi.c
··· 569 569 nhi->hop_count); 570 570 INIT_WORK(&nhi->interrupt_work, nhi_interrupt_work); 571 571 572 - nhi->tx_rings = devm_kzalloc(&pdev->dev, 573 - nhi->hop_count * sizeof(*nhi->tx_rings), 574 - GFP_KERNEL); 575 - nhi->rx_rings = devm_kzalloc(&pdev->dev, 576 - nhi->hop_count * sizeof(*nhi->rx_rings), 577 - GFP_KERNEL); 572 + nhi->tx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count, 573 + sizeof(*nhi->tx_rings), GFP_KERNEL); 574 + nhi->rx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count, 575 + sizeof(*nhi->rx_rings), GFP_KERNEL); 578 576 if (!nhi->tx_rings || !nhi->rx_rings) 579 577 return -ENOMEM; 580 578