Skip to content

Commit

Permalink
i915/perf: Fix NULL deref bugs with drm_dbg() calls
Browse files Browse the repository at this point in the history
When i915 perf interface is not available dereferencing it will lead to
NULL dereferences.

As returning -ENOTSUPP is pretty clear return when perf interface is not
available.

Fixes: 2fec539 ("i915/perf: Replace DRM_DEBUG with driver specific drm_dbg call")
Suggested-by: Tvrtko Ursulin <[email protected]>
Signed-off-by: Harshit Mogalapalli <[email protected]>
Reviewed-by: Tvrtko Ursulin <[email protected]>
Cc: <[email protected]> # v6.0+
Signed-off-by: Tvrtko Ursulin <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
[tursulin: added stable tag]
(cherry picked from commit 36f2735)
Signed-off-by: Jani Nikula <[email protected]>
  • Loading branch information
harshimogalapalli authored and jnikula committed Oct 30, 2023
1 parent ce4941c commit 471aa95
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions drivers/gpu/drm/i915/i915_perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4227,11 +4227,8 @@ int i915_perf_open_ioctl(struct drm_device *dev, void *data,
u32 known_open_flags;
int ret;

if (!perf->i915) {
drm_dbg(&perf->i915->drm,
"i915 perf interface not available for this system\n");
if (!perf->i915)
return -ENOTSUPP;
}

known_open_flags = I915_PERF_FLAG_FD_CLOEXEC |
I915_PERF_FLAG_FD_NONBLOCK |
Expand Down Expand Up @@ -4607,11 +4604,8 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
struct i915_oa_reg *regs;
int err, id;

if (!perf->i915) {
drm_dbg(&perf->i915->drm,
"i915 perf interface not available for this system\n");
if (!perf->i915)
return -ENOTSUPP;
}

if (!perf->metrics_kobj) {
drm_dbg(&perf->i915->drm,
Expand Down Expand Up @@ -4773,11 +4767,8 @@ int i915_perf_remove_config_ioctl(struct drm_device *dev, void *data,
struct i915_oa_config *oa_config;
int ret;

if (!perf->i915) {
drm_dbg(&perf->i915->drm,
"i915 perf interface not available for this system\n");
if (!perf->i915)
return -ENOTSUPP;
}

if (i915_perf_stream_paranoid && !perfmon_capable()) {
drm_dbg(&perf->i915->drm,
Expand Down

0 comments on commit 471aa95

Please sign in to comment.