Linux Kernels

staging: android: ion: tegra: Use devm_kcalloc instead of devm_kzalloc

This change “staging: android: ion: tegra: Use devm_kcalloc instead of devm_kzalloc” (commit 0969e3d) in Linux kernel is authored by Amitoj Kaur Chawla <amitoj1606 [at] gmail.com> on Thu Feb 25 19:25:04 2016 +0530.

Description of "staging: android: ion: tegra: Use devm_kcalloc instead of devm_kzalloc"

The change “staging: android: ion: tegra: Use devm_kcalloc instead of devm_kzalloc” introduces changes as follows.

staging: android: ion: tegra: Use devm_kcalloc instead of devm_kzalloc

Replace devm_kzalloc with devm_kcalloc to ensure there are no integer
overflows from the multiplication of a number * sizeof.

The following Coccinelle semantic patch was used to make this change:
//<smpl>
@@
expression dev,E1,E3;
type T;
@@
- devm_kzalloc(dev,E1*sizeof(T),E3)
+ devm_kcalloc(dev,E1,sizeof(T),E3)
//</smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Linux kernel releases containing commit 0969e3d

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "staging: android: ion: tegra: Use devm_kcalloc instead of devm_kzalloc"

There are 5 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/staging/android/ion/tegra/tegra_ion.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
 
diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c
index 4d3c516cc15e..88285243d53d 100644
--- a/drivers/staging/android/ion/tegra/tegra_ion.c
+++ b/drivers/staging/android/ion/tegra/tegra_ion.c
@@ -33,9 +33,8 @@ static int tegra_ion_probe(struct platform_device *pdev)
 
 	num_heaps = pdata->nr;
 
-	heaps = devm_kzalloc(&pdev->dev,
-			     sizeof(struct ion_heap *) * pdata->nr,
-			     GFP_KERNEL);
+	heaps = devm_kcalloc(&pdev->dev, pdata->nr,
+			     sizeof(struct ion_heap *), GFP_KERNEL);
 
 	idev = ion_device_create(NULL);
 	if (IS_ERR_OR_NULL(idev))

The commit for this change in Linux stable tree is 0969e3d (patch).

Last modified: 2020/01/11 09:26