[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220607164942.431058986@linuxfoundation.org>
Date: Tue, 7 Jun 2022 18:58:40 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: linux-kernel@...r.kernel.org
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
stable@...r.kernel.org, Colin Ian King <colin.i.king@...il.com>,
"Juan A. Suarez" <jasuarez@...lia.com>,
Melissa Wen <melissa.srw@...il.com>,
Sasha Levin <sashal@...nel.org>
Subject: [PATCH 5.15 255/667] drm/v3d: Fix null pointer dereference of pointer perfmon
From: Colin Ian King <colin.i.king@...il.com>
[ Upstream commit ce7a1ecf3f9f1fccaf67295307614511d8e11b13 ]
In the unlikely event that pointer perfmon is null the WARN_ON return path
occurs after the pointer has already been deferenced. Fix this by only
dereferencing perfmon after it has been null checked.
Fixes: 26a4dc29b74a ("drm/v3d: Expose performance counters to userspace")
Signed-off-by: Colin Ian King <colin.i.king@...il.com>
Reviewed-by: Juan A. Suarez <jasuarez@...lia.com>
Signed-off-by: Melissa Wen <melissa.srw@...il.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220424183512.1365683-1-colin.i.king@gmail.com
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
drivers/gpu/drm/v3d/v3d_perfmon.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/v3d/v3d_perfmon.c b/drivers/gpu/drm/v3d/v3d_perfmon.c
index 0288ef063513..f6a88abccc7d 100644
--- a/drivers/gpu/drm/v3d/v3d_perfmon.c
+++ b/drivers/gpu/drm/v3d/v3d_perfmon.c
@@ -25,11 +25,12 @@ void v3d_perfmon_start(struct v3d_dev *v3d, struct v3d_perfmon *perfmon)
{
unsigned int i;
u32 mask;
- u8 ncounters = perfmon->ncounters;
+ u8 ncounters;
if (WARN_ON_ONCE(!perfmon || v3d->active_perfmon))
return;
+ ncounters = perfmon->ncounters;
mask = GENMASK(ncounters - 1, 0);
for (i = 0; i < ncounters; i++) {
--
2.35.1
Powered by blists - more mailing lists