drm/amd/display: guard for virtual calling destroy_link_encoders
authorMartin Leung <martin.leung@amd.com>
Fri, 19 Feb 2021 23:04:42 +0000 (18:04 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 5 Jul 2022 20:12:37 +0000 (16:12 -0400)
[Why]:
On power down, virtual dal may try to delete link_encoders by
referencing uninitialized res_pool.

[How]:
Added guard against empty res_pool.

Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Martin Leung <martin.leung@amd.com>
Tested-by: Daniel Wheeler <daniel.wheeler@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc.c

index 795766c..34a3e1e 100644 (file)
@@ -347,10 +347,16 @@ static bool create_link_encoders(struct dc *dc)
  */
 static void destroy_link_encoders(struct dc *dc)
 {
-       unsigned int num_usb4_dpia = dc->res_pool->res_cap->num_usb4_dpia;
-       unsigned int num_dig_link_enc = dc->res_pool->res_cap->num_dig_link_enc;
+       unsigned int num_usb4_dpia;
+       unsigned int num_dig_link_enc;
        int i;
 
+       if (!dc->res_pool)
+               return;
+
+       num_usb4_dpia = dc->res_pool->res_cap->num_usb4_dpia;
+       num_dig_link_enc = dc->res_pool->res_cap->num_dig_link_enc;
+
        /* A platform without USB4 DPIA endpoints has a fixed mapping between DIG
         * link encoders and physical display endpoints and does not require
         * additional link encoder objects.