Skip to content

Commit ffdd27d

Browse files
qianfengrongMani-Sadhasivam
authored andcommitted
PCI: keystone: Use kcalloc() instead of kzalloc()
Replace calls of devm_kzalloc() with devm_kcalloc() in ks_pcie_probe(). As noted in the kernel documentation [1], open-coded multiplication in allocator arguments is discouraged because it can lead to integer overflow. Using devm_kcalloc() provides built-in overflow protection, making the memory allocation safer when calculating the allocation size compared to explicit multiplication. [1]: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Signed-off-by: Qianfeng Rong <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Siddharth Vadapalli <[email protected]> Link: https://patch.msgid.link/[email protected]
1 parent 8f5ae30 commit ffdd27d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/pci/controller/dwc/pci-keystone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,11 +1213,11 @@ static int ks_pcie_probe(struct platform_device *pdev)
12131213
if (ret)
12141214
num_lanes = 1;
12151215

1216-
phy = devm_kzalloc(dev, sizeof(*phy) * num_lanes, GFP_KERNEL);
1216+
phy = devm_kcalloc(dev, num_lanes, sizeof(*phy), GFP_KERNEL);
12171217
if (!phy)
12181218
return -ENOMEM;
12191219

1220-
link = devm_kzalloc(dev, sizeof(*link) * num_lanes, GFP_KERNEL);
1220+
link = devm_kcalloc(dev, num_lanes, sizeof(*link), GFP_KERNEL);
12211221
if (!link)
12221222
return -ENOMEM;
12231223

0 commit comments

Comments
 (0)