summaryrefslogtreecommitdiffstats
path: root/drivers/thunderbolt
diff options
context:
space:
mode:
authorHimangi Saraogi <himangi774@gmail.com>2014-07-12 01:12:43 +0530
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-07-13 13:16:50 -0700
commit2a211f320ee3d86835b40efd2948642482d3c933 (patch)
treeeea9f41ae4a1c16b7938585e3b9a34e85bb40989 /drivers/thunderbolt
parent95b4ecbf759ae8ecf40462ed5e6a08023166a05c (diff)
downloadlinux-stable-2a211f320ee3d86835b40efd2948642482d3c933.tar.gz
linux-stable-2a211f320ee3d86835b40efd2948642482d3c933.tar.bz2
linux-stable-2a211f320ee3d86835b40efd2948642482d3c933.zip
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>
Diffstat (limited to 'drivers/thunderbolt')
-rw-r--r--drivers/thunderbolt/nhi.c10
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)
nhi->hop_count);
INIT_WORK(&nhi->interrupt_work, nhi_interrupt_work);
- nhi->tx_rings = devm_kzalloc(&pdev->dev,
- nhi->hop_count * sizeof(*nhi->tx_rings),
- GFP_KERNEL);
- nhi->rx_rings = devm_kzalloc(&pdev->dev,
- nhi->hop_count * sizeof(*nhi->rx_rings),
- GFP_KERNEL);
+ nhi->tx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count,
+ sizeof(*nhi->tx_rings), GFP_KERNEL);
+ nhi->rx_rings = devm_kcalloc(&pdev->dev, nhi->hop_count,
+ sizeof(*nhi->rx_rings), GFP_KERNEL);
if (!nhi->tx_rings || !nhi->rx_rings)
return -ENOMEM;