Skip to contentSkip to conversation

Fixes: b6e336dbeda8 ("staging: android: ion: Convert hi6220 to common platform")

PATCH In review sayli karnik 3 participants 3 messages Sep 23, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Fixes: b6e336dbeda8 ("staging: android: ion: Convert hi6220 to common platform")

The sizeof function must take pointer to the ion_heap structure as an argument when allocating memory for ipdev->heaps. This patch changes the sizeof argument from (struct ion_heap) to (struct ion_heap *) which is a pointer to the structure.

---
v2:
Fixed the error due to a previous commit
Updated the subject line

 drivers/staging/android/ion/hisilicon/hi6220_ion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/android/ion/hisilicon/hi6220_ion.c +1 -1
index 659aa71..f9a64e7 100644
@@ -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(struct ion_heap *) * ipdev->data->nr,
 				GFP_KERNEL);
 	if (!ipdev->heaps) {
 		ion_destroy_platform_data(ipdev->data);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 6 lines · sayli karnik

The sizeof function must take pointer to the ion_heap structure as an argument when allocating memory for ipdev->heaps. This patch changes the sizeof argument from (struct ion_heap) to (struct ion_heap *) which is a pointer to the structure.

The "fixes:" line needs to be above the signed-off-by: line, not in the subject of the patch. Look at commits in the kernel tree for lots of examples of how to format this.

third time's a charm?

thanks,

greg k-h

#2 lore raw
In reply to sayli karnik
Quoted 4 lines · sayli karnik

The sizeof function must take pointer to the ion_heap structure as an argument when allocating memory for ipdev->heaps. This patch changes the sizeof argument from (struct ion_heap) to (struct ion_heap *) which is a pointer to the structure.

The sentence "The sizeof function must take pointer to the ion_heap structure as an argument..." is not very clear. Why must it do that? And actually, here sizeof is taking a type as an argument, not a pointer to a structure, so the terminology is not quite right.

Basically, the issue is do you want a pointer to a structure, or a pointer to an array of pointers. You have made the latter choice. You need to look at how the array is used to identify why it is the correct choice.

Hint: it may be helpful to look at other files that use such values in the same way.

Hint 2: There is at least one other bug lurking nearby, and the other file that contains code similar to this one has a nearby bug too, although not exactly the same one.

julia

Quoted 33 lines

---
v2:
Fixed the error due to a previous commit
Updated the subject line

 drivers/staging/android/ion/hisilicon/hi6220_ion.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/android/ion/hisilicon/hi6220_ion.c +1 -2
index 659aa71..f9a64e7 100644
@@ -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(struct ion_heap *) * ipdev->data->nr,
 				GFP_KERNEL);
 	if (!ipdev->heaps) {
 		ion_destroy_platform_data(ipdev->data);
--

2.7.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160923154221.GA4993%40sayli-HP-15-Notebook-PC.
For more options, visit https://groups.google.com/d/optout.