Skip to contentSkip to conversation

drm/amdgpu: fix a NULL check in debugfs init

PATCH New Dan Carpenter 1 participant 1 message Sep 26, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: fix a NULL check in debugfs init

The debugfs_create_file() returns error pointers if DEBUGFS isn't enabled. But here, we know that it is enabled so it returns NULL on error which could lead to a NULL dereference a few lines later.

---
If someone wanted to delete the error handling as well that would also be fine, but I decided not to bother with that.

drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c +2 -2
index f5fb93795a69..0d806dfd5eeb 100644
@@ -832,12 +832,12 @@ int amdgpu_debugfs_regs_init(struct amdgpu_device *adev)
 		ent = debugfs_create_file(debugfs_regs_names[i],
 					  S_IFREG | S_IRUGO, root,
 					  adev, debugfs_regs[i]);
-		if (IS_ERR(ent)) {
+		if (!ent) {
 			for (j = 0; j < i; j++) {
 				debugfs_remove(adev->debugfs_regs[i]);
 				adev->debugfs_regs[i] = NULL;
 			}
-			return PTR_ERR(ent);
+			return -ENOMEM;
 		}
 
 		if (!i)

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx