drm/amd/display: No need for Null pointer check before kfree
authorDeepak R Varma <drv@mailo.com>
Tue, 27 Dec 2022 18:39:51 +0000 (00:09 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 10 Jan 2023 23:04:53 +0000 (18:04 -0500)
kfree() & vfree() internally performs NULL check on the pointer handed
to it and take no action if it indeed is NULL. Hence there is no need
for a pre-check of the memory pointer before handing it to
kfree()/vfree().

Issue reported by ifnullfree.cocci Coccinelle semantic patch script.

Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Deepak R Varma <drv@mailo.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c
drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c

index 3ce0ee0..694a9d3 100644 (file)
@@ -577,8 +577,7 @@ void dcn3_clk_mgr_construct(
 
 void dcn3_clk_mgr_destroy(struct clk_mgr_internal *clk_mgr)
 {
-       if (clk_mgr->base.bw_params)
-               kfree(clk_mgr->base.bw_params);
+       kfree(clk_mgr->base.bw_params);
 
        if (clk_mgr->wm_range_table)
                dm_helpers_free_gpu_mem(clk_mgr->base.ctx, DC_MEM_ALLOC_TYPE_GART,
index 200fcec..ba9814f 100644 (file)
@@ -783,8 +783,7 @@ void dcn32_clk_mgr_construct(
 
 void dcn32_clk_mgr_destroy(struct clk_mgr_internal *clk_mgr)
 {
-       if (clk_mgr->base.bw_params)
-               kfree(clk_mgr->base.bw_params);
+       kfree(clk_mgr->base.bw_params);
 
        if (clk_mgr->wm_range_table)
                dm_helpers_free_gpu_mem(clk_mgr->base.ctx, DC_MEM_ALLOC_TYPE_GART,