[bug report] drm/amd/powerplay: add control gfxoff enabling in late init

Dan Carpenter dan.carpenter at oracle.com
Thu May 17 14:13:44 UTC 2018


Hello Huang Rui,

The patch 9667849bbb8d: "drm/amd/powerplay: add control gfxoff
enabling in late init" from Mar 13, 2018, leads to the following
static checker warning:

	drivers/gpu/drm/amd/amdgpu/../powerplay/amd_powerplay.c:194 pp_late_init()
	error: we previously assumed 'hwmgr' could be null (see line 185)

drivers/gpu/drm/amd/amdgpu/../powerplay/amd_powerplay.c
   179  static int pp_late_init(void *handle)
   180  {
   181          struct amdgpu_device *adev = handle;
   182          struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
   183          int ret;
   184  
   185          if (hwmgr && hwmgr->pm_en) {
                    ^^^^^
Check

   186                  mutex_lock(&hwmgr->smu_lock);
   187                  hwmgr_handle_task(hwmgr,
   188                                          AMD_PP_TASK_COMPLETE_INIT, NULL);
   189                  mutex_unlock(&hwmgr->smu_lock);
   190          }
   191          if (adev->pm.smu_prv_buffer_size != 0)
   192                  pp_reserve_vram_for_smu(adev);
   193  
   194          if (hwmgr->hwmgr_func->gfx_off_control &&
                    ^^^^^^^^^^^^^^^^^^
Patch adds unchecked dereference.

   195              (hwmgr->feature_mask & PP_GFXOFF_MASK)) {
   196                  ret = hwmgr->hwmgr_func->gfx_off_control(hwmgr, true);
   197                  if (ret)
   198                          pr_err("gfx off enabling failed!\n");
   199          }
   200  
   201          return 0;
   202  }

regards,
dan carpenter


More information about the amd-gfx mailing list