[PATCH] drm/amd/powerplay: add NULL check for vega10_ps

From: Markov Gleb

Date: Mon Jun 29 2026 - 09:41:43 EST


From: Gleb Markov <markov.gi@xxxxxxxxxx>

cast_phw_vega10_power_state() can return NULL and the return result must
be checked.

Add a NULL check to avoid NULL derederence.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: f83a9991648b ("drm/amd/powerplay: add Vega10 powerplay support (v5)")
Co-developed-by: Mikhail Titov <titov.ma@xxxxxxxxxx>
Signed-off-by: Mikhail Titov <titov.ma@xxxxxxxxxx>
Signed-off-by: Gleb Markov <markov.gi@xxxxxxxxxx>
---
drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
index c8c9fb827bda..83e62ab9c7f4 100644
--- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
+++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/vega10_hwmgr.c
@@ -3844,6 +3844,8 @@ static uint32_t vega10_dpm_get_sclk(struct pp_hwmgr *hwmgr, bool low)
return -EINVAL;

vega10_ps = cast_phw_vega10_power_state(&ps->hardware);
+ if (vega10_ps == NULL)
+ return -EINVAL;

if (low)
return vega10_ps->performance_levels[0].gfx_clock;
@@ -3866,6 +3868,8 @@ static uint32_t vega10_dpm_get_mclk(struct pp_hwmgr *hwmgr, bool low)
return -EINVAL;

vega10_ps = cast_phw_vega10_power_state(&ps->hardware);
+ if (vega10_ps == NULL)
+ return -EINVAL;

if (low)
return vega10_ps->performance_levels[0].mem_clock;
--
2.43.0