Skip to content

Commit 5f70132

Browse files
committed
drm/vc4: perfmon: Fix variable dereferenced before check
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 <[email protected]> Reported-by: Dan Carpenter <[email protected]> Fixes: 30f8c74 ("drm/vc4: Warn if some v3d code is run on BCM2711") Signed-off-by: Maxime Ripard <[email protected]> Reviewed-by: José Expósito <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 85016f6 commit 5f70132

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

drivers/gpu/drm/vc4/vc4_perfmon.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,16 @@
1717

1818
void vc4_perfmon_get(struct vc4_perfmon *perfmon)
1919
{
20-
struct vc4_dev *vc4 = perfmon->dev;
20+
struct vc4_dev *vc4;
2121

22+
if (!perfmon)
23+
return;
24+
25+
vc4 = perfmon->dev;
2226
if (WARN_ON_ONCE(vc4->is_vc5))
2327
return;
2428

25-
if (perfmon)
26-
refcount_inc(&perfmon->refcnt);
29+
refcount_inc(&perfmon->refcnt);
2730
}
2831

2932
void vc4_perfmon_put(struct vc4_perfmon *perfmon)

0 commit comments

Comments
 (0)