Skip to contentSkip to conversation

drm/nouveau: Fix potential memory access error in nouveau_debugfs_pstate_get()

PATCH Superseded Lyude Paul 1 participant 1 message Jul 31, 2018

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Lyude Paul

author maintainer
#0 lore raw

PATCH v2 1/1 drm/nouveau: Fix potential memory access error in nouveau_debugfs_pstate_get()

nouveau_debugfs(drm) will never be NULL, because we're taking the value of the potentially null device pointer and adding to it so it isn't 0x0. So, check if drm is NULL instead.

---
Forgot to hit :w before committing, whoops!

 drivers/gpu/drm/nouveau/nouveau_debugfs.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/nouveau/nouveau_debugfs.c +5 -3
index 963a4dba8213..8e758c4cb4fd 100644
@@ -50,13 +50,15 @@ static int
 nouveau_debugfs_pstate_get(struct seq_file *m, void *data)
 {
 	struct drm_device *drm = m->private;
-	struct nouveau_debugfs *debugfs = nouveau_debugfs(drm);
-	struct nvif_object *ctrl = &debugfs->ctrl;
+	struct nouveau_debugfs *debugfs;
+	struct nvif_object *ctrl;
 	struct nvif_control_pstate_info_v0 info = {};
 	int ret, i;
 
-	if (!debugfs)
+	if (!drm)
 		return -ENODEV;
+	debugfs = nouveau_debugfs(drm);
+	ctrl = &debugfs->ctrl;
 
 	ret = nvif_mthd(ctrl, NVIF_CONTROL_PSTATE_INFO, &info, sizeof(info));
 	if (ret)
Signature · 6 lines
2.17.1

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau