drm/amd/display: Add null checker before passing variables
authorjsg <jsg@openbsd.org>
Thu, 15 Aug 2024 03:08:00 +0000 (03:08 +0000)
committerjsg <jsg@openbsd.org>
Thu, 15 Aug 2024 03:08:00 +0000 (03:08 +0000)
From Alex Hung
4cc2a94d96caeb3c975acdae7351c2f997c32175 in linux-6.6.y/6.6.46
8092aa3ab8f7b737a34b71f91492c676a843043a in mainline linux

sys/dev/pci/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index cf5afb4..6a3d1f4 100644 (file)
@@ -2632,7 +2632,8 @@ static int dm_suspend(void *handle)
 
                dm->cached_dc_state = dc_copy_state(dm->dc->current_state);
 
-               dm_gpureset_toggle_interrupts(adev, dm->cached_dc_state, false);
+               if (dm->cached_dc_state)
+                       dm_gpureset_toggle_interrupts(adev, dm->cached_dc_state, false);
 
                amdgpu_dm_commit_zero_streams(dm->dc);
 
@@ -6487,7 +6488,8 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
                aconnector->dc_sink = aconnector->dc_link->local_sink ?
                aconnector->dc_link->local_sink :
                aconnector->dc_em_sink;
-               dc_sink_retain(aconnector->dc_sink);
+               if (aconnector->dc_sink)
+                       dc_sink_retain(aconnector->dc_sink);
        }
 }
 
@@ -7300,7 +7302,8 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector)
                                drm_add_modes_noedid(connector, 1920, 1080);
        } else {
                amdgpu_dm_connector_ddc_get_modes(connector, edid);
-               amdgpu_dm_connector_add_common_modes(encoder, connector);
+               if (encoder)
+                       amdgpu_dm_connector_add_common_modes(encoder, connector);
                amdgpu_dm_connector_add_freesync_modes(connector, edid);
        }
        amdgpu_dm_fbc_init(connector);