diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-07-11 15:42:43 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-07-13 16:16:50 -0400 |
commit | 2a211f320ee3d86835b40efd2948642482d3c933 (patch) | |
tree | eea9f41ae4a1c16b7938585e3b9a34e85bb40989 | |
parent | 95b4ecbf759ae8ecf40462ed5e6a08023166a05c (diff) |
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>
-rw-r--r-- | drivers/thunderbolt/nhi.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index ce72f31fe0d8..c68fe1222c16 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c | |||
@@ -569,12 +569,10 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id) | |||
569 | nhi->hop_count); | 569 | nhi->hop_count); |
570 | INIT_WORK(&nhi->interrupt_work, nhi_interrupt_work); | 570 | INIT_WORK(&nhi->interrupt_work, nhi_interrupt_work); |
571 | 571 | ||
572 | nhi->tx_rings = devm_kzalloc(&pdev->dev, | 572 | nhi->tx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count, |
573 | nhi->hop_count * sizeof(*nhi->tx_rings), | 573 | sizeof(*nhi->tx_rings), GFP_KERNEL); |
574 | GFP_KERNEL); | 574 | nhi->rx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count, |
575 | nhi->rx_rings = devm_kzalloc(&pdev->dev, | 575 | sizeof(*nhi->rx_rings), GFP_KERNEL); |
576 | nhi->hop_count * sizeof(*nhi->rx_rings), | ||
577 | GFP_KERNEL); | ||
578 | if (!nhi->tx_rings || !nhi->rx_rings) | 576 | if (!nhi->tx_rings || !nhi->rx_rings) |
579 | return -ENOMEM; | 577 | return -ENOMEM; |
580 | 578 | ||