Commit 5f701324 authored by Maxime Ripard's avatar Maxime Ripard

drm/vc4: perfmon: Fix variable dereferenced before check

Commit 30f8c74c ("drm/vc4: Warn if some v3d code is run on BCM2711")
introduced a check in vc4_perfmon_get() that dereferences a pointer before
we checked whether that pointer is valid or not.

Let's rework that function a bit to do things in the proper order.
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Fixes: 30f8c74c ("drm/vc4: Warn if some v3d code is run on BCM2711")
Signed-off-by: default avatarMaxime Ripard <maxime@cerno.tech>
Reviewed-by: default avatarJosé Expósito <jose.exposito89@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220622080243.22119-1-maxime@cerno.tech
parent 85016f66
...@@ -17,12 +17,15 @@ ...@@ -17,12 +17,15 @@
void vc4_perfmon_get(struct vc4_perfmon *perfmon) void vc4_perfmon_get(struct vc4_perfmon *perfmon)
{ {
struct vc4_dev *vc4 = perfmon->dev; struct vc4_dev *vc4;
if (!perfmon)
return;
vc4 = perfmon->dev;
if (WARN_ON_ONCE(vc4->is_vc5)) if (WARN_ON_ONCE(vc4->is_vc5))
return; return;
if (perfmon)
refcount_inc(&perfmon->refcnt); refcount_inc(&perfmon->refcnt);
} }
......
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