All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: android: ion: hisilicon: Use pointer to memory being allocated as the sizeof argument
@ 2016-09-21 15:41 sayli karnik
  2016-09-21 16:15 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: sayli karnik @ 2016-09-21 15:41 UTC (permalink / raw)
  To: outreachy-kernel
  Cc: Laura Abbott, Sumit Semwal, Greg Kroah-Hartman,
	Arve Hjønnevåg, Riley Andrews

This patch finds cases where the argument to sizeof is wrong in memory
allocation functions by checking the type of the allocated memory when it is a
double pointer and ensuring the sizeof argument takes a pointer to the memory
being allocated.
Done using coccinelle:
@@
type T;
T **x;
@@

  x =
  <+...sizeof(
- T
+ *x
  )...+>

Signed-off-by: sayli karnik <karniksayli1995@gmail.com>
---
 drivers/staging/android/ion/hisilicon/hi6220_ion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/android/ion/hisilicon/hi6220_ion.c b/drivers/staging/android/ion/hisilicon/hi6220_ion.c
index 659aa71..9f9b244 100644
--- a/drivers/staging/android/ion/hisilicon/hi6220_ion.c
+++ b/drivers/staging/android/ion/hisilicon/hi6220_ion.c
@@ -57,7 +57,7 @@ static int hi6220_ion_probe(struct platform_device *pdev)
 		return PTR_ERR(ipdev->data);
 
 	ipdev->heaps = devm_kzalloc(&pdev->dev,
-				sizeof(struct ion_heap)*ipdev->data->nr,
+				sizeof(*ipdev->heaps) * ipdev->data->nr,
 				GFP_KERNEL);
 	if (!ipdev->heaps) {
 		ion_destroy_platform_data(ipdev->data);
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-21 16:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21 15:41 [PATCH] staging: android: ion: hisilicon: Use pointer to memory being allocated as the sizeof argument sayli karnik
2016-09-21 16:15 ` Greg Kroah-Hartman
2016-09-21 16:31   ` sayli karnik
2016-09-21 16:36     ` [Outreachy kernel] " Julia Lawall
2016-09-21 16:41     ` Greg Kroah-Hartman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.