* [PATCH 0/2] drm/amd/display: Adjustments for dc_create()
@ 2020-12-19 17:44 Markus Elfring
2020-12-19 17:46 ` [PATCH 1/2] drm/amd/display: Return directly after a failed kzalloc() in dc_create() Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Markus Elfring @ 2020-12-19 17:44 UTC (permalink / raw)
To: amd-gfx, dri-devel, Alex Deucher, Alvin Lee, Anthony Koo,
Aric Cyr, Aurabindo Pillai, Bhawanpreet Lakha, Chiawen Huang,
Christian König, Harry Wentland, Leo Li, Nicholas Kazlauskas,
Yongqiang Sun, Daniel Vetter, David Airlie
Cc: kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] drm/amd/display: Return directly after a failed kzalloc() in dc_create()
2020-12-19 17:44 [PATCH 0/2] drm/amd/display: Adjustments for dc_create() Markus Elfring
@ 2020-12-19 17:46 ` Markus Elfring
2020-12-19 17:48 ` [PATCH 2/2] drm/amd/display: Use common error handling code " Markus Elfring
2020-12-22 15:08 ` [PATCH 0/2] drm/amd/display: Adjustments for dc_create() Alex Deucher
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2020-12-19 17:46 UTC (permalink / raw)
To: amd-gfx, dri-devel, Alex Deucher, Alvin Lee, Anthony Koo,
Aric Cyr, Aurabindo Pillai, Bhawanpreet Lakha, Chiawen Huang,
Christian König, Harry Wentland, Leo Li, Nicholas Kazlauskas,
Yongqiang Sun, Daniel Vetter, David Airlie
Cc: kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/gpu/drm/amd/display/dc/core/dc.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 7339d9855ec8..e35fbfcb4d0e 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -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
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] drm/amd/display: Use common error handling code in dc_create()
2020-12-19 17:44 [PATCH 0/2] drm/amd/display: Adjustments for dc_create() Markus Elfring
2020-12-19 17:46 ` [PATCH 1/2] drm/amd/display: Return directly after a failed kzalloc() in dc_create() Markus Elfring
@ 2020-12-19 17:48 ` Markus Elfring
2020-12-22 15:08 ` [PATCH 0/2] drm/amd/display: Adjustments for dc_create() Alex Deucher
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2020-12-19 17:48 UTC (permalink / raw)
To: amd-gfx, dri-devel, Alex Deucher, Alvin Lee, Anthony Koo,
Aric Cyr, Aurabindo Pillai, Bhawanpreet Lakha, Chiawen Huang,
Christian König, Harry Wentland, Leo Li, Nicholas Kazlauskas,
Yongqiang Sun, Daniel Vetter, David Airlie
Cc: kernel-janitors, LKML
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/gpu/drm/amd/display/dc/core/dc.c | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
index e35fbfcb4d0e..64344c054c93 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -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
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 0/2] drm/amd/display: Adjustments for dc_create()
2020-12-19 17:44 [PATCH 0/2] drm/amd/display: Adjustments for dc_create() Markus Elfring
2020-12-19 17:46 ` [PATCH 1/2] drm/amd/display: Return directly after a failed kzalloc() in dc_create() Markus Elfring
2020-12-19 17:48 ` [PATCH 2/2] drm/amd/display: Use common error handling code " Markus Elfring
@ 2020-12-22 15:08 ` Alex Deucher
2 siblings, 0 replies; 4+ messages in thread
From: Alex Deucher @ 2020-12-22 15:08 UTC (permalink / raw)
To: Markus Elfring
Cc: Aric Cyr, Daniel Vetter, Leo Li, Bhawanpreet Lakha, Chiawen Huang,
LKML, Maling list - DRI developers, Nicholas Kazlauskas,
David Airlie, kernel-janitors, Aurabindo Pillai, amd-gfx list,
Yongqiang Sun, Harry Wentland, Alex Deucher, Anthony Koo,
Christian König, Alvin Lee
On Sun, Dec 20, 2020 at 6:10 AM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 19 Dec 2020 18:30:56 +0100
>
> Two update suggestions were taken into account
> from static source code analysis.
>
Applied. Thanks!
Alex
> 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
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-12-22 15:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-19 17:44 [PATCH 0/2] drm/amd/display: Adjustments for dc_create() Markus Elfring
2020-12-19 17:46 ` [PATCH 1/2] drm/amd/display: Return directly after a failed kzalloc() in dc_create() Markus Elfring
2020-12-19 17:48 ` [PATCH 2/2] drm/amd/display: Use common error handling code " Markus Elfring
2020-12-22 15:08 ` [PATCH 0/2] drm/amd/display: Adjustments for dc_create() Alex Deucher
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox