From: Colin King <colin.king@canonical.com>
To: "Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>,
"David Airlie" <airlied@linux.ie>,
"Eric Huang" <JinHuiEric.Huang@amd.com>,
"Rex Zhu" <Rex.Zhu@amd.com>, "Jammy Zhou" <Jammy.Zhou@amd.com>,
"Tom St Denis" <tom.stdenis@amd.com>,
"Dan Carpenter" <dan.carpenter@oracle.com>,
dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] drm/amd/amdgpu: default to zero number of states if not enabled
Date: Thu, 6 Oct 2016 19:02:11 +0100 [thread overview]
Message-ID: <20161006180211.31747-1-colin.king@canonical.com> (raw)
From: Colin Ian King <colin.king@canonical.com>
Currently, if adev->pp_enabled is false then the pp_stats_info data
is not read and hence a garbage number of states from the stack
is used to dump out the number of states. Given data.nums could be
any random value, this could easily lead to read outside the
data.states array. Fix this by setting data.nums to zero if
adev->pp_enabled is false.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
index accc908..808d788 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
@@ -195,6 +195,8 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
if (adev->pp_enabled)
amdgpu_dpm_get_pp_num_states(adev, &data);
+ else
+ data.nums = 0;
buf_len = snprintf(buf, PAGE_SIZE, "states: %d\n", data.nums);
for (i = 0; i < data.nums; i++)
--
2.9.3
next reply other threads:[~2016-10-06 18:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-06 18:02 Colin King [this message]
2016-10-06 18:32 ` [PATCH] drm/amd/amdgpu: default to zero number of states if not enabled Alex Deucher
2016-10-06 19:03 ` Colin Ian King
2016-10-06 19:04 ` Deucher, Alexander
2016-10-06 19:05 ` Colin Ian King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161006180211.31747-1-colin.king@canonical.com \
--to=colin.king@canonical.com \
--cc=Jammy.Zhou@amd.com \
--cc=JinHuiEric.Huang@amd.com \
--cc=Rex.Zhu@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=christian.koenig@amd.com \
--cc=dan.carpenter@oracle.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tom.stdenis@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox