drm/amd/display: Adjustments for dc_create()
cover drm/amd/display: Adjustments for dc_create()
From: Markus Elfring <[email protected]>
Date: Sat, 19 Dec 2020 18:30:56 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Return directly after a failed kzalloc()
Use common error handling code
drivers/gpu/drm/amd/display/dc/core/dc.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)
--
2.29.2
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 1/2 drm/amd/display: Return directly after a failed kzalloc() in dc_create()
From: Markus Elfring <[email protected]>
Date: Sat, 19 Dec 2020 18:04:33 +0100
* Return directly after a call of the function “kzalloc” failed at the beginning.
* Delete a label which became unnecessary with this refactoring.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +2 -4
@@ -964,8 +964,8 @@ struct dc *dc_create(const struct dc_init_data *init_params)struct dc *dc =kzalloc (sizeof (*dc),GFP_KERNEL );unsigned int full_pipe_count; -if (NULL == dc) - goto alloc_fail; +if (!dc) +return NULL ;if (init_params->dce_environment ==DCE_ENV_VIRTUAL_HW ) {if (false ==dc_construct_ctx (dc, init_params)) {
@@ -1009,8 +1009,6 @@ struct dc *dc_create(const struct dc_init_data *init_params) construct_fail:kfree (dc); - -alloc_fail:return NULL ; }
--
2.29.2
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 2/2 drm/amd/display: Use common error handling code in dc_create()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Sat, 19 Dec 2020 18:18:59 +0100
Adjust a jump target so that a bit of exception handling can be better reused at the end of this function.
--- drivers/gpu/drm/amd/display/dc/core/dc.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc.c +6 -9
@@ -968,15 +968,11 @@ struct dc *dc_create(const struct dc_init_data *init_params)return NULL ;if (init_params->dce_environment ==DCE_ENV_VIRTUAL_HW ) { -if (false ==dc_construct_ctx (dc, init_params)) { -dc_destruct (dc); - goto construct_fail; - } +if (!dc_construct_ctx (dc, init_params)) + goto destruct_dc; }else { -if (false ==dc_construct (dc, init_params)) { -dc_destruct (dc); - goto construct_fail; - } +if (!dc_construct (dc, init_params)) + goto destruct_dc; full_pipe_count = dc->res_pool->pipe_count;if (dc->res_pool->underlay_pipe_index !=NO_UNDERLAY_PIPE )
@@ -1007,7 +1003,8 @@ struct dc *dc_create(const struct dc_init_data *init_params)return dc; -construct_fail: +destruct_dc: +dc_destruct (dc);kfree (dc);return NULL ; }
--
2.29.2
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Alex Deucher
AppliedQuoted 7 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Sat, 19 Dec 2020 18:30:56 +0100Two update suggestions were taken into account
from static source code analysis.
Applied. Thanks!
Alex
Quoted 14 lines
Markus Elfring (2):
Return directly after a failedkzalloc()
Use common error handling codedrivers/gpu/drm/amd/display/dc/core/dc.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-)--
2.29.2_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx