debugfs_create_file() can return an error pointer if debugfs is disabled or it can return NULL on error.
Signed-off-by: Dan Carpenter dan.carpenter@oracle.com
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c index 36be03c..adba2a1 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c @@ -1980,6 +1980,8 @@ static int amdgpu_debugfs_regs_init(struct amdgpu_device *adev) adev, &amdgpu_debugfs_regs_fops); if (IS_ERR(ent)) return PTR_ERR(ent); + if (!ent) + return -ENOMEM; i_size_write(ent->d_inode, adev->rmmio_size); adev->debugfs_regs = ent;
On Thu, Jun 11, 2015 at 04:35:26PM +0200, walter harms wrote:
To be honest, I don't know why debugfs_create_file() doesn't just return NULL when it is configured out. I think I have asked this before...
I think the answer is that it seemed like a good idea at the time. These days we would probably prefer to use:
if (enabled(CONFIG_DEBUGFS)) {
to test if it's there or not. Maybe that's still the right thing to check here.
But debugfs error handling is designed so that under normal situations you don't have to check for errors. It turns out that everyone still does because they are used to checking for errors.
The only reason we have to check here is because we do:
i_size_write(ent->d_inode, adev->rmmio_size); ^^^^^^^^^^^^
Dereference.
regards, dan carpenter
dri-devel@lists.freedesktop.org