From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> Date: Sun, 23 Nov 2014 18:48:15 +0100 The functions ion_heap_destroy() and vfree() perform also input parameter validation. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx> --- drivers/staging/android/ion/ion.c | 6 ++---- drivers/staging/android/ion/ion_dummy_driver.c | 6 ++---- drivers/staging/android/ion/tegra/tegra_ion.c | 6 ++---- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 2703609..df12cc3 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -263,8 +263,7 @@ err: heap->ops->unmap_dma(heap, buffer); heap->ops->free(buffer); err1: - if (buffer->pages) - vfree(buffer->pages); + vfree(buffer->pages); err2: kfree(buffer); return ERR_PTR(ret); @@ -276,8 +275,7 @@ void ion_buffer_destroy(struct ion_buffer *buffer) buffer->heap->ops->unmap_kernel(buffer->heap, buffer); buffer->heap->ops->unmap_dma(buffer->heap, buffer); buffer->heap->ops->free(buffer); - if (buffer->pages) - vfree(buffer->pages); + vfree(buffer->pages); kfree(buffer); } diff --git a/drivers/staging/android/ion/ion_dummy_driver.c b/drivers/staging/android/ion/ion_dummy_driver.c index 3a45e79..d06bf52 100644 --- a/drivers/staging/android/ion/ion_dummy_driver.c +++ b/drivers/staging/android/ion/ion_dummy_driver.c @@ -112,10 +112,8 @@ static int __init ion_dummy_init(void) } return 0; err: - for (i = 0; i < dummy_ion_pdata.nr; i++) { - if (heaps[i]) - ion_heap_destroy(heaps[i]); - } + for (i = 0; i < dummy_ion_pdata.nr; ++i) + ion_heap_destroy(heaps[i]); kfree(heaps); if (carveout_ptr) { diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c index 11c7cce..5b8ef0e 100644 --- a/drivers/staging/android/ion/tegra/tegra_ion.c +++ b/drivers/staging/android/ion/tegra/tegra_ion.c @@ -54,10 +54,8 @@ static int tegra_ion_probe(struct platform_device *pdev) platform_set_drvdata(pdev, idev); return 0; err: - for (i = 0; i < num_heaps; i++) { - if (heaps[i]) - ion_heap_destroy(heaps[i]); - } + for (i = 0; i < num_heaps; ++i) + ion_heap_destroy(heaps[i]); return err; } -- 2.1.3 -- To unsubscribe from this list: send the line "unsubscribe linux-tegra" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html