Skip to contentSkip to conversation

drm/amd/display: Fix a potential NULL dereference

PATCH Applied Dan Carpenter 2 participants 2 messages Jan 25, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: Fix a potential NULL dereference

The debug printk dereferences "link->link_enc" before we have ensured that it is non-NULL. Fix this potential NULL derefence by moving the printk after the check.

Fixes 1975b95ad4e7 ("drm/amd/display: Log link/connector info provided in BIOS object table")
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +2 -2
index c16af3983fdb..4d31b2fae1f9 100644
@@ -1525,13 +1525,13 @@ static bool dc_link_construct(struct dc_link *link,
 	link->link_enc  		link->dc->res_pool->funcs->link_enc_create(&enc_init_data);
 
-	DC_LOG_DC("BIOS object table - DP_IS_USB_C: %d", link->link_enc->features.flags.bits.DP_IS_USB_C);
-
 	if (!link->link_enc) {
 		DC_ERROR("Failed to create link encoder!\n");
 		goto link_enc_create_fail;
 	}
 
+	DC_LOG_DC("BIOS object table - DP_IS_USB_C: %d", link->link_enc->features.flags.bits.DP_IS_USB_C);
+
 	link->link_enc_hw_inst = link->link_enc->transmitter;
 
 	for (i = 0; i < 4; i++) {
Signature · 1 line
2.29.2
Applied
#1 lore raw
Quoted 7 lines · Dan Carpenter

The debug printk dereferences "link->link_enc" before we have ensured that it is non-NULL. Fix this potential NULL derefence by moving the printk after the check.

Fixes 1975b95ad4e7 ("drm/amd/display: Log link/connector info provided in BIOS object table")

Applied. Thanks!

Alex

Quoted 30 lines
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/dc/core/dc_link.c +2 -3
index c16af3983fdb..4d31b2fae1f9 100644
@@ -1525,13 +1525,13 @@ static bool dc_link_construct(struct dc_link *link,
        link->link_enc >                 link->dc->res_pool->funcs->link_enc_create(&enc_init_data);
 
-       DC_LOG_DC("BIOS object table - DP_IS_USB_C: %d", link->link_enc->features.flags.bits.DP_IS_USB_C);
-
        if (!link->link_enc) {
                DC_ERROR("Failed to create link encoder!\n");
                goto link_enc_create_fail;
        }
 
+       DC_LOG_DC("BIOS object table - DP_IS_USB_C: %d", link->link_enc->features.flags.bits.DP_IS_USB_C);
+
        link->link_enc_hw_inst = link->link_enc->transmitter;
 
        for (i = 0; i < 4; i++) {
--

2.29.2

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx