OSDN Git Service

drm/amd/amdgpu: Fix debugfs error handling
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 14 Jun 2018 14:45:23 +0000 (17:45 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 16 Oct 2018 20:10:34 +0000 (15:10 -0500)
commitd344b21bf405eed05963627bfed6dd3df422623c
tree7f23cd9c6b0f5bfe51ff52a3616c85714f7e0f2f
parentc55045adf7210d246a016c961916f078ed31a951
drm/amd/amdgpu: Fix debugfs error handling

The error handling is wrong and "ent" could be NULL we when dereference
it to get "ent->d_inode".

The thing is that normally debugfs_create_file() is not supposed to
require (or have) any error handling.  That function does return error
pointers if debugfs is turned off but we know it's enable here.  When
it's enabled, then it returns NULL on error.

So what I did was I stripped out all the error handling except around
the i_size_write().  I could have just used a NULL check instead of an
IS_ERR_OR_NULL() but I figured this was more clear because that way you
don't have to look at the surrounding code to see whether debugfs is
enabled or not.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c