[PATCH 5/5] drm/amd/display: Move an expression into a return statement in dcn201_link_encoder_create()
Markus Elfring
Markus.Elfring at web.de
Tue Apr 11 13:50:14 UTC 2023
Date: Tue, 11 Apr 2023 14:04:57 +0200
The address of a data structure member was determined before
a corresponding null pointer check in the implementation of
the function “dcn201_link_encoder_create”.
Thus avoid the risk for undefined behaviour by moving the usage
of an expression into a return statement.
This issue was detected by using the Coccinelle software.
Fixes: 3f68c01be9a2227de1e190317fe34a6fb835a094 ("drm/amd/display: add cyan_skillfish display support")
Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
---
drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
index 6ea70da28aaa..a1b44c7bd34b 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn201/dcn201_resource.c
@@ -791,7 +791,6 @@ static struct link_encoder *dcn201_link_encoder_create(
{
struct dcn20_link_encoder *enc20 =
kzalloc(sizeof(struct dcn20_link_encoder), GFP_ATOMIC);
- struct dcn10_link_encoder *enc10 = &enc20->enc10;
if (!enc20)
return NULL;
@@ -804,8 +803,7 @@ static struct link_encoder *dcn201_link_encoder_create(
&link_enc_hpd_regs[enc_init_data->hpd_source],
&le_shift,
&le_mask);
-
- return &enc10->base;
+ return &enc20->enc10.base;
}
static struct clock_source *dcn201_clock_source_create(
--
2.40.0
More information about the amd-gfx
mailing list