Commit ce7a1ecf authored by Colin Ian King's avatar Colin Ian King Committed by Melissa Wen

drm/v3d: Fix null pointer dereference of pointer perfmon

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: 26a4dc29 ("drm/v3d: Expose performance counters to userspace")
Signed-off-by: default avatarColin Ian King <colin.i.king@gmail.com>
Reviewed-by: default avatarJuan A. Suarez <jasuarez@igalia.com>
Signed-off-by: default avatarMelissa Wen <melissa.srw@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220424183512.1365683-1-colin.i.king@gmail.com
parent 2deb9739
...@@ -25,11 +25,12 @@ void v3d_perfmon_start(struct v3d_dev *v3d, struct v3d_perfmon *perfmon) ...@@ -25,11 +25,12 @@ void v3d_perfmon_start(struct v3d_dev *v3d, struct v3d_perfmon *perfmon)
{ {
unsigned int i; unsigned int i;
u32 mask; u32 mask;
u8 ncounters = perfmon->ncounters; u8 ncounters;
if (WARN_ON_ONCE(!perfmon || v3d->active_perfmon)) if (WARN_ON_ONCE(!perfmon || v3d->active_perfmon))
return; return;
ncounters = perfmon->ncounters;
mask = GENMASK(ncounters - 1, 0); mask = GENMASK(ncounters - 1, 0);
for (i = 0; i < ncounters; i++) { for (i = 0; i < ncounters; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment