浏览代码

drm/amdgpu: Don't crash system if we can't get crtc

Signed-off-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Harry Wentland 9 年之前
父节点
当前提交
9ddf940f5d
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

+ 6 - 0
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

@@ -727,6 +727,12 @@ int amdgpu_get_vblank_timestamp_kms(struct drm_device *dev, unsigned int pipe,
 
 	/* Get associated drm_crtc: */
 	crtc = &adev->mode_info.crtcs[pipe]->base;
+	if (!crtc) {
+		/* This can occur on driver load if some component fails to
+		 * initialize completely and driver is unloaded */
+		DRM_ERROR("Uninitialized crtc %d\n", pipe);
+		return -EINVAL;
+	}
 
 	/* Helper routine in DRM core does all the work: */
 	return drm_calc_vbltimestamp_from_scanoutpos(dev, pipe, max_error,