staging:android: Introduce the use of the managed version of kzalloc
authorHimangi Saraogi <himangi774@gmail.com>
Thu, 6 Mar 2014 23:50:20 +0000 (05:20 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Mar 2014 23:36:48 +0000 (15:36 -0800)
This patch moves shared private data kzalloc to managed devm_kzalloc and
cleans now unneccessary kfree in probe and remove functions.

Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/android/ion/tegra/tegra_ion.c

index 3474c65f87faad262a29f25542338758dd9d7004..11c7cceb3c7d52f89f6cd99372d3a656aeeec0b5 100644 (file)
@@ -32,13 +32,13 @@ 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);
+       if (IS_ERR_OR_NULL(idev))
                return PTR_ERR(idev);
-       }
 
        /* create the heaps as specified in the board file */
        for (i = 0; i < num_heaps; i++) {
@@ -58,7 +58,6 @@ err:
                if (heaps[i])
                        ion_heap_destroy(heaps[i]);
        }
-       kfree(heaps);
        return err;
 }
 
@@ -70,7 +69,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;
 }