> -----Original Message----- > From: amd-gfx [mailto:amd-gfx-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf > Of Alex Deucher > Sent: Friday, April 19, 2019 10:26 PM > To: Li, Sun peng (Leo) <Sunpeng.Li@xxxxxxx> > Cc: Gui, Jack <Jack.Gui@xxxxxxx>; amd-gfx list <amd- > gfx@xxxxxxxxxxxxxxxxxxxxx> > Subject: Re: [PATCH] drm/amdgpu: Check if smu.ppt_funcs is initialized > before accessing > > On Thu, Apr 18, 2019 at 12:01 PM <sunpeng.li@xxxxxxx> wrote: > > > > From: Leo Li <sunpeng.li@xxxxxxx> > > > > smu.ppt_funcs is only initialized for specific SMU versions. > > > > On a Hawaii ASIC, attempting to access the udev attribute > > ATTRS{power_dpm_state} will cause a null pointer deref in > > amdgpu_get_dpm_state() because of this. > > > > Fix by checking that ppt_funcs is initialized first. > > > > CC: Chengming Gui <Jack.Gui@xxxxxxx> > > Signed-off-by: Leo Li <sunpeng.li@xxxxxxx> > > --- > > drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > > index 4b7a076..7993623 100644 > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c > > @@ -144,7 +144,7 @@ static ssize_t amdgpu_get_dpm_state(struct device > *dev, > > struct amdgpu_device *adev = ddev->dev_private; > > enum amd_pm_state_type pm; > > > > - if (adev->smu.ppt_funcs->get_current_power_state) > > + if (adev->smu.ppt_funcs && adev->smu.ppt_funcs- > >get_current_power_state) > > For consistency, I think we probably want something like: > if (is_support_sw_smu(adev) && adev->smu.ppt_funcs- > >get_current_power_state) > > Either way: > Reviewed-by: Alex Deucher <alexander.deucher@xxxxxxx> Yes. The same comment with me. Please use is_support_sw_smu() to check it. With that fixed, please add Reviewed-by: Huang Rui <ray.huang@xxxxxxx> > > > pm = amdgpu_smu_get_current_power_state(adev); > > else if (adev->powerplay.pp_funcs->get_current_power_state) > > pm = amdgpu_dpm_get_current_power_state(adev); > > -- > > 2.7.4 > > > > _______________________________________________ > > amd-gfx mailing list > > amd-gfx@xxxxxxxxxxxxxxxxxxxxx > > https://lists.freedesktop.org/mailman/listinfo/amd-gfx > _______________________________________________ > amd-gfx mailing list > amd-gfx@xxxxxxxxxxxxxxxxxxxxx > https://lists.freedesktop.org/mailman/listinfo/amd-gfx _______________________________________________ amd-gfx mailing list amd-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/amd-gfx