* [PATCH] drm/amdgpu: fix a NULL check in debugfs init
@ 2018-09-26 10:41 Dan Carpenter
0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2018-09-26 10:41 UTC (permalink / raw)
To: Alex Deucher
Cc: Tom St Denis, David (ChunMing) Zhou, Andrey Grodzovsky,
David Airlie, kernel-janitors-u79uwXL29TY76Z2rM5mHXA,
amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Huang Rui,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, Rex Zhu,
Christian König
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.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
If someone wanted to delete the error handling as well that would also
be fine, but I decided not to bother with that.
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
index f5fb93795a69..0d806dfd5eeb 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -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)
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2018-09-26 10:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-26 10:41 [PATCH] drm/amdgpu: fix a NULL check in debugfs init Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox