From: Mario Limonciello <mario.limoncie...@amd.com>

[WHY]
Although unlikely drm_atomic_get_new_connector_state() or
drm_atomic_get_old_connector_state() can return NULL.

[HOW]
Check returns before dereference.

Cc: Mario Limonciello <mario.limoncie...@amd.com>
Cc: Alex Deucher <alexander.deuc...@amd.com>
Cc: sta...@vger.kernel.org
Reviewed-by: Harry Wentland <harry.wentl...@amd.com>
Signed-off-by: Mario Limonciello <mario.limoncie...@amd.com>
Signed-off-by: Alex Hung <alex.h...@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 176f420effd9..b944abea306d 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -7836,6 +7836,9 @@ amdgpu_dm_connector_atomic_check(struct drm_connector 
*conn,
        struct amdgpu_dm_connector *aconn = to_amdgpu_dm_connector(conn);
        int ret;
 
+       if (WARN_ON(unlikely(!old_con_state || !new_con_state)))
+               return -EINVAL;
+
        trace_amdgpu_dm_connector_atomic_check(new_con_state);
 
        if (conn->connector_type == DRM_MODE_CONNECTOR_DisplayPort) {
-- 
2.43.0

Reply via email to