[Intel-gfx] [PATCH] drm/i915: fix ifnullfree.cocci warnings

kbuild test robot lkp at intel.com
Sun Jul 9 09:05:10 UTC 2017


drivers/gpu/drm/i915/i915_perf.c:3313:2-7: 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/i915/i915_perf.c:3315:2-7: 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/i915/i915_perf.c:3317:2-7: 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: 7f475c52e3f8 ("drm/i915: Implement I915_PERF_ADD/REMOVE_CONFIG interface")
CC: Matthew Auld <matthew.auld at intel.com>
Signed-off-by: Fengguang Wu <fengguang.wu at intel.com>
---

 i915_perf.c |    9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -3309,12 +3309,9 @@ int i915_perf_remove_config_ioctl(struct
 
 	sysfs_remove_group(dev_priv->perf.metrics_kobj,
 			   &oa_config->sysfs_metric);
-	if (oa_config->flex_regs)
-		kfree(oa_config->flex_regs);
-	if (oa_config->b_counter_regs)
-		kfree(oa_config->b_counter_regs);
-	if (oa_config->mux_regs)
-		kfree(oa_config->mux_regs);
+	kfree(oa_config->flex_regs);
+	kfree(oa_config->b_counter_regs);
+	kfree(oa_config->mux_regs);
 	kfree(oa_config);
 
 config_err:


More information about the Intel-gfx mailing list