[PATCH] binder: fix ifnullfree.cocci warnings

From: kbuild test robot
Date: Tue Nov 22 2016 - 09:49:52 EST


drivers/android/binder.c:3705:2-20: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/android/binder.c:3708:2-20: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/android/binder.c:3711:2-20: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/android/binder.c:3714:2-20: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/android/binder.c:3717:2-20: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/android/binder.c:3720:2-20: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.
drivers/android/binder.c:3723:2-20: WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values.

NULL check before some freeing functions is not needed.

Based on checkpatch warning
"kfree(NULL) is safe this check is probably not required"
and kfreeaddr.cocci by Julia Lawall.

Generated by: scripts/coccinelle/free/ifnullfree.cocci

CC: Ganesh Mahendran <opensource.ganesh@xxxxxxxxx>
Signed-off-by: Fengguang Wu <fengguang.wu@xxxxxxxxx>
---

binder.c | 21 +++++++--------------
1 file changed, 7 insertions(+), 14 deletions(-)

--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -3701,26 +3701,19 @@ BINDER_DEBUG_ENTRY(transaction_log);

static void binder_destroy_cache(void)
{
- if (binder_proc_cachep)
- kmem_cache_destroy(binder_proc_cachep);
+ kmem_cache_destroy(binder_proc_cachep);

- if (binder_thread_cachep)
- kmem_cache_destroy(binder_thread_cachep);
+ kmem_cache_destroy(binder_thread_cachep);

- if (binder_node_cachep)
- kmem_cache_destroy(binder_node_cachep);
+ kmem_cache_destroy(binder_node_cachep);

- if (binder_ref_cachep)
- kmem_cache_destroy(binder_ref_cachep);
+ kmem_cache_destroy(binder_ref_cachep);

- if (binder_transaction_cachep)
- kmem_cache_destroy(binder_transaction_cachep);
+ kmem_cache_destroy(binder_transaction_cachep);

- if (binder_work_cachep)
- kmem_cache_destroy(binder_work_cachep);
+ kmem_cache_destroy(binder_work_cachep);

- if (binder_ref_death_cachep)
- kmem_cache_destroy(binder_ref_death_cachep);
+ kmem_cache_destroy(binder_ref_death_cachep);
}

static int __init binder_create_cache(void)