linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/powerplay: Variable ps could be NULL when it get dereferenced
@ 2019-08-30  4:35 Yizhuo
  0 siblings, 0 replies; only message in thread
From: Yizhuo @ 2019-08-30  4:35 UTC (permalink / raw)
  Cc: csong, zhiyunq, Yizhuo, Alex Deucher, Christian König,
	David Airlie, amd-gfx, dri-devel, linux-kernel

Inside function cz_get_performance_level(), pointer ps could be NULL via
cast_const_PhwCzPowerState(). However, this pointer is dereferenced
without any check, which is potentially unsafe.

Signed-off-by: Yizhuo <yzhai003@ucr.edu>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
index bc839ff0bdd0..d2628e7b612d 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/cz_hwmgr.c
@@ -1799,6 +1799,9 @@ static int cz_get_performance_level(struct pp_hwmgr *hwmgr, const struct pp_hw_p
 	data = (struct cz_hwmgr *)(hwmgr->backend);
 	ps = cast_const_PhwCzPowerState(state);
 
+	if (!ps)
+		return -EINVAL;
+
 	level_index = index > ps->level - 1 ? ps->level - 1 : index;
 	level->coreClock = ps->levels[level_index].engineClock;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-08-30  4:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30  4:35 [PATCH] drm/amd/powerplay: Variable ps could be NULL when it get dereferenced Yizhuo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).