drm/amd/display: fix ifnullfree.cocci warnings
authorkbuild test robot <[email protected]>
Thu, 12 Oct 2017 23:17:48 +0000 (07:17 +0800)
committerAlex Deucher <[email protected]>
Sat, 21 Oct 2017 20:50:37 +0000 (16:50 -0400)
drivers/gpu/drm/amd/amdgpu/../display/dc/gpio/gpio_service.c:134:3-8: 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/gpu/drm/amd/amdgpu/../display/dc/gpio/gpio_service.c:175:4-9: 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

Fixes: f09cd1f46388 ("drm/amd/display: Use kernel alloc/free")
Signed-off-by: Fengguang Wu <[email protected]>
Reviewed-by: Harry Wentland <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c

index ff9d36b5866e0b659d072fde7962905c5d309cb1..80038e0e610f4e093502bb1364cac0d7495d8d33 100644 (file)
@@ -130,8 +130,7 @@ failure_2:
 
                slot = service->busyness[index_of_id];
 
-               if (slot)
-                       kfree(slot);
+               kfree(slot);
        }
 
 failure_1:
@@ -171,8 +170,7 @@ void dal_gpio_service_destroy(
                do {
                        uint32_t *slot = (*ptr)->busyness[index_of_id];
 
-                       if (slot)
-                               kfree(slot);
+                       kfree(slot);
 
                        ++index_of_id;
                } while (index_of_id < GPIO_ID_COUNT);