Message ID | Y6s7989gmBZldV/S@qemulion (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | drm/amd/display: No need for Null pointer check before kfree | expand |
On Wed, Dec 28, 2022 at 12:09:51AM +0530, Deepak R Varma wrote: > 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. > > Signed-off-by: Deepak R Varma <drv@mailo.com> > --- Hello, Requesting a review and feedback on this patch proposal. Thank you, ./drv
On 12/27/22 13:39, Deepak R Varma wrote: > 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. > > Signed-off-by: Deepak R Varma <drv@mailo.com> > --- > drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c | 3 +-- > drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c | 3 +-- > 2 files changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c > index 3ce0ee0d012f..694a9d3d92ae 100644 > --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c > +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c > @@ -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, > diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c > index 200fcec19186..ba9814f88f48 100644 > --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c > +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c > @@ -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, > -- > 2.34.1 > > > Hi, Reviewed-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com> And applied to amd-staging-drm-next. Thanks Siqueira
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c index 3ce0ee0d012f..694a9d3d92ae 100644 --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c @@ -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, diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c index 200fcec19186..ba9814f88f48 100644 --- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c +++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c @@ -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,
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. Signed-off-by: Deepak R Varma <drv@mailo.com> --- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c | 3 +-- drivers/gpu/drm/amd/display/dc/clk_mgr/dcn32/dcn32_clk_mgr.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) -- 2.34.1