diff mbox

[OPW,kernel] staging:tegra_ion:Fix the use of kzalloc using coccinelle semantic patch

Message ID 1394699983-24287-1-git-send-email-swetha.kanagala@gmail.com
State New, archived
Headers show

Commit Message

swetha.kanagala@gmail.com March 13, 2014, 8:39 a.m. UTC
From: Swetha Kanagala <swetha.kanagala@gmail.com>

Use devm_kzalloc instead of kzalloc and remove corresponding kfree.

Signed-off-by: Swetha Kanagala <swetha.kanagala@gmail.com>
---
 drivers/staging/android/ion/tegra/tegra_ion.c |    7 +++----
 drivers/staging/nvec/nvec_ps2.c               |    2 +-
 2 files changed, 4 insertions(+), 5 deletions(-)

Comments

Nick Kossifidis March 13, 2014, 12:50 p.m. UTC | #1
2014-03-13 8:39 GMT+00:00  <swetha.kanagala@gmail.com>:
> From: Swetha Kanagala <swetha.kanagala@gmail.com>
>
> Use devm_kzalloc instead of kzalloc and remove corresponding kfree.
>
> Signed-off-by: Swetha Kanagala <swetha.kanagala@gmail.com>

Hello Swetha :-)

drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
is part of NVEC (NVidia compliant Embedded Controller) not tegra_ion.

Please send a separate patch for that one.
Julia Lawall March 13, 2014, 1:25 p.m. UTC | #2
> drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
> is part of NVEC (NVidia compliant Embedded Controller) not tegra_ion.
>
> Please send a separate patch for that one.

Actually, in linux-next the code is already updated.

julia
Sarah Sharp March 13, 2014, 11:32 p.m. UTC | #3
On Thu, Mar 13, 2014 at 02:09:43PM +0530, swetha.kanagala@gmail.com wrote:
> From: Swetha Kanagala <swetha.kanagala@gmail.com>
> 
> Use devm_kzalloc instead of kzalloc and remove corresponding kfree.

In the future, please include the semantic patch in your patch
description.

Thanks,
Sarah Sharp

> 
> Signed-off-by: Swetha Kanagala <swetha.kanagala@gmail.com>
> ---
>  drivers/staging/android/ion/tegra/tegra_ion.c |    7 +++----
>  drivers/staging/nvec/nvec_ps2.c               |    2 +-
>  2 files changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c
> index 3474c65..cc89d0d 100644
> --- a/drivers/staging/android/ion/tegra/tegra_ion.c
> +++ b/drivers/staging/android/ion/tegra/tegra_ion.c
> @@ -32,11 +32,12 @@ static int tegra_ion_probe(struct platform_device *pdev)
>  
>  	num_heaps = pdata->nr;
>  
> -	heaps = kzalloc(sizeof(struct ion_heap *) * pdata->nr, GFP_KERNEL);
> +	heaps = devm_kzalloc(&pdev->dev,
> +			     sizeof(struct ion_heap *) * pdata->nr,
> +			     GFP_KERNEL);
>  
>  	idev = ion_device_create(NULL);
>  	if (IS_ERR_OR_NULL(idev)) {
> -		kfree(heaps);
>  		return PTR_ERR(idev);
>  	}
>  
> @@ -58,7 +59,6 @@ err:
>  		if (heaps[i])
>  			ion_heap_destroy(heaps[i]);
>  	}
> -	kfree(heaps);
>  	return err;
>  }
>  
> @@ -70,7 +70,6 @@ static int tegra_ion_remove(struct platform_device *pdev)
>  	ion_device_destroy(idev);
>  	for (i = 0; i < num_heaps; i++)
>  		ion_heap_destroy(heaps[i]);
> -	kfree(heaps);
>  	return 0;
>  }
>  
> diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
> index 06dbb02..45b2f13 100644
> --- a/drivers/staging/nvec/nvec_ps2.c
> +++ b/drivers/staging/nvec/nvec_ps2.c
> @@ -106,7 +106,7 @@ static int nvec_mouse_probe(struct platform_device *pdev)
>  	struct serio *ser_dev;
>  	char mouse_reset[] = { NVEC_PS2, SEND_COMMAND, PSMOUSE_RST, 3 };
>  
> -	ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL);
> +	ser_dev = devm_kzalloc(&pdev->dev, sizeof(struct serio), GFP_KERNEL);
>  	if (ser_dev == NULL)
>  		return -ENOMEM;
>  
> -- 
> 1.7.9.5
> 
> -- 
> You received this message because you are subscribed to the Google Groups "opw-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to opw-kernel+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
diff mbox

Patch

diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c
index 3474c65..cc89d0d 100644
--- a/drivers/staging/android/ion/tegra/tegra_ion.c
+++ b/drivers/staging/android/ion/tegra/tegra_ion.c
@@ -32,11 +32,12 @@  static int tegra_ion_probe(struct platform_device *pdev)
 
 	num_heaps = pdata->nr;
 
-	heaps = kzalloc(sizeof(struct ion_heap *) * pdata->nr, GFP_KERNEL);
+	heaps = devm_kzalloc(&pdev->dev,
+			     sizeof(struct ion_heap *) * pdata->nr,
+			     GFP_KERNEL);
 
 	idev = ion_device_create(NULL);
 	if (IS_ERR_OR_NULL(idev)) {
-		kfree(heaps);
 		return PTR_ERR(idev);
 	}
 
@@ -58,7 +59,6 @@  err:
 		if (heaps[i])
 			ion_heap_destroy(heaps[i]);
 	}
-	kfree(heaps);
 	return err;
 }
 
@@ -70,7 +70,6 @@  static int tegra_ion_remove(struct platform_device *pdev)
 	ion_device_destroy(idev);
 	for (i = 0; i < num_heaps; i++)
 		ion_heap_destroy(heaps[i]);
-	kfree(heaps);
 	return 0;
 }
 
diff --git a/drivers/staging/nvec/nvec_ps2.c b/drivers/staging/nvec/nvec_ps2.c
index 06dbb02..45b2f13 100644
--- a/drivers/staging/nvec/nvec_ps2.c
+++ b/drivers/staging/nvec/nvec_ps2.c
@@ -106,7 +106,7 @@  static int nvec_mouse_probe(struct platform_device *pdev)
 	struct serio *ser_dev;
 	char mouse_reset[] = { NVEC_PS2, SEND_COMMAND, PSMOUSE_RST, 3 };
 
-	ser_dev = kzalloc(sizeof(struct serio), GFP_KERNEL);
+	ser_dev = devm_kzalloc(&pdev->dev, sizeof(struct serio), GFP_KERNEL);
 	if (ser_dev == NULL)
 		return -ENOMEM;