Skip to content

Commit

Permalink
drm/vc4: perfmon: Fix variable dereferenced before check
Browse files Browse the repository at this point in the history
Commit 30f8c74 ("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: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 30f8c74 ("drm/vc4: Warn if some v3d code is run on BCM2711")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: José Expósito <jose.exposito89@gmail.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220622080243.22119-1-maxime@cerno.tech
  • Loading branch information
Maxime Ripard committed Jun 27, 2022
1 parent 85016f6 commit 5f70132
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/gpu/drm/vc4/vc4_perfmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@

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))
return;

if (perfmon)
refcount_inc(&perfmon->refcnt);
refcount_inc(&perfmon->refcnt);
}

void vc4_perfmon_put(struct vc4_perfmon *perfmon)
Expand Down

0 comments on commit 5f70132

Please sign in to comment.