Commit fb37e128 authored by Markus Elfring's avatar Markus Elfring Committed by Michael Ellerman

powerpc/powernv/pci: Use kmalloc_array() in two functions

Use kmalloc_array(), which checks for overflow of the multiplication,
rather than doing it by hand.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 4ab2537c
...@@ -1326,7 +1326,9 @@ static int pnv_pci_vf_assign_m64(struct pci_dev *pdev, u16 num_vfs) ...@@ -1326,7 +1326,9 @@ static int pnv_pci_vf_assign_m64(struct pci_dev *pdev, u16 num_vfs)
else else
m64_bars = 1; m64_bars = 1;
pdn->m64_map = kmalloc(sizeof(*pdn->m64_map) * m64_bars, GFP_KERNEL); pdn->m64_map = kmalloc_array(m64_bars,
sizeof(*pdn->m64_map),
GFP_KERNEL);
if (!pdn->m64_map) if (!pdn->m64_map)
return -ENOMEM; return -ENOMEM;
/* Initialize the m64_map to IODA_INVALID_M64 */ /* Initialize the m64_map to IODA_INVALID_M64 */
...@@ -1593,7 +1595,8 @@ int pnv_pci_sriov_enable(struct pci_dev *pdev, u16 num_vfs) ...@@ -1593,7 +1595,8 @@ int pnv_pci_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
/* Allocating pe_num_map */ /* Allocating pe_num_map */
if (pdn->m64_single_mode) if (pdn->m64_single_mode)
pdn->pe_num_map = kmalloc(sizeof(*pdn->pe_num_map) * num_vfs, pdn->pe_num_map = kmalloc_array(num_vfs,
sizeof(*pdn->pe_num_map),
GFP_KERNEL); GFP_KERNEL);
else else
pdn->pe_num_map = kmalloc(sizeof(*pdn->pe_num_map), GFP_KERNEL); pdn->pe_num_map = kmalloc(sizeof(*pdn->pe_num_map), GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment